Fixed database update to new version
This commit is contained in:
parent
21273f822c
commit
8b73d93d1a
@ -80,7 +80,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 309
|
versionCode 310
|
||||||
versionName "1.8.0"
|
versionName "1.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,9 @@ package org.telegram.SQLite;
|
|||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.ui.ApplicationLoader;
|
import org.telegram.ui.ApplicationLoader;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SQLiteDatabase {
|
public class SQLiteDatabase {
|
||||||
private final int sqliteHandle;
|
private final int sqliteHandle;
|
||||||
|
|
||||||
private final Map<String, SQLitePreparedStatement> preparedMap = new HashMap<String, SQLitePreparedStatement>();
|
|
||||||
private boolean isOpen = false;
|
private boolean isOpen = false;
|
||||||
private boolean inTransaction = false;
|
private boolean inTransaction = false;
|
||||||
|
|
||||||
@ -36,23 +32,13 @@ public class SQLiteDatabase {
|
|||||||
return executeInt(s, tableName) != null;
|
return executeInt(s, tableName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(String sql, Object... args) throws SQLiteException {
|
|
||||||
checkOpened();
|
|
||||||
SQLiteCursor cursor = query(sql, args);
|
|
||||||
try {
|
|
||||||
cursor.next();
|
|
||||||
} finally {
|
|
||||||
cursor.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SQLitePreparedStatement executeFast(String sql) throws SQLiteException {
|
public SQLitePreparedStatement executeFast(String sql) throws SQLiteException {
|
||||||
return new SQLitePreparedStatement(this, sql, true);
|
return new SQLitePreparedStatement(this, sql, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer executeInt(String sql, Object... args) throws SQLiteException {
|
public Integer executeInt(String sql, Object... args) throws SQLiteException {
|
||||||
checkOpened();
|
checkOpened();
|
||||||
SQLiteCursor cursor = query(sql, args);
|
SQLiteCursor cursor = queryFinalized(sql, args);
|
||||||
try {
|
try {
|
||||||
if (!cursor.next()) {
|
if (!cursor.next()) {
|
||||||
return null;
|
return null;
|
||||||
@ -63,18 +49,6 @@ public class SQLiteDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLiteCursor query(String sql, Object... args) throws SQLiteException {
|
|
||||||
checkOpened();
|
|
||||||
SQLitePreparedStatement stmt = preparedMap.get(sql);
|
|
||||||
|
|
||||||
if (stmt == null) {
|
|
||||||
stmt = new SQLitePreparedStatement(this, sql, false);
|
|
||||||
preparedMap.put(sql, stmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stmt.query(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SQLiteCursor queryFinalized(String sql, Object... args) throws SQLiteException {
|
public SQLiteCursor queryFinalized(String sql, Object... args) throws SQLiteException {
|
||||||
checkOpened();
|
checkOpened();
|
||||||
return new SQLitePreparedStatement(this, sql, true).query(args);
|
return new SQLitePreparedStatement(this, sql, true).query(args);
|
||||||
@ -83,9 +57,6 @@ public class SQLiteDatabase {
|
|||||||
public void close() {
|
public void close() {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
try {
|
try {
|
||||||
for (SQLitePreparedStatement stmt : preparedMap.values()) {
|
|
||||||
stmt.finalizeQuery();
|
|
||||||
}
|
|
||||||
commitTransaction();
|
commitTransaction();
|
||||||
closedb(sqliteHandle);
|
closedb(sqliteHandle);
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user