Cleanup DBHelper in prep for package table in the future.
This commit is contained in:
parent
45f9379fee
commit
486e8e699f
@ -95,7 +95,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
+ "PRIMARY KEY (" + ApkTable.Cols.APP_ID + ", " + ApkTable.Cols.VERSION_CODE + ", " + ApkTable.Cols.REPO_ID + ")"
|
+ "PRIMARY KEY (" + ApkTable.Cols.APP_ID + ", " + ApkTable.Cols.VERSION_CODE + ", " + ApkTable.Cols.REPO_ID + ")"
|
||||||
+ ");";
|
+ ");";
|
||||||
|
|
||||||
static final String CREATE_TABLE_APP = "CREATE TABLE " + AppMetadataTable.NAME
|
static final String CREATE_TABLE_APP_METADATA = "CREATE TABLE " + AppMetadataTable.NAME
|
||||||
+ " ( "
|
+ " ( "
|
||||||
+ AppMetadataTable.Cols.PACKAGE_NAME + " text not null, "
|
+ AppMetadataTable.Cols.PACKAGE_NAME + " text not null, "
|
||||||
+ AppMetadataTable.Cols.NAME + " text not null, "
|
+ AppMetadataTable.Cols.NAME + " text not null, "
|
||||||
@ -248,7 +248,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
|
||||||
db.execSQL(CREATE_TABLE_APP);
|
db.execSQL(CREATE_TABLE_APP_METADATA);
|
||||||
db.execSQL(CREATE_TABLE_APK);
|
db.execSQL(CREATE_TABLE_APK);
|
||||||
db.execSQL(CREATE_TABLE_INSTALLED_APP);
|
db.execSQL(CREATE_TABLE_INSTALLED_APP);
|
||||||
db.execSQL(CREATE_TABLE_REPO);
|
db.execSQL(CREATE_TABLE_REPO);
|
||||||
@ -731,12 +731,18 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
.putBoolean("triedEmptyUpdate", false)
|
.putBoolean("triedEmptyUpdate", false)
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
db.execSQL("DROP TABLE " + AppMetadataTable.NAME);
|
db.beginTransaction();
|
||||||
db.execSQL("DROP TABLE " + ApkTable.NAME);
|
try {
|
||||||
db.execSQL(CREATE_TABLE_APP);
|
db.execSQL("DROP TABLE " + AppMetadataTable.NAME);
|
||||||
db.execSQL(CREATE_TABLE_APK);
|
db.execSQL("DROP TABLE " + ApkTable.NAME);
|
||||||
clearRepoEtags(db);
|
db.execSQL(CREATE_TABLE_APP_METADATA);
|
||||||
ensureIndexes(db);
|
db.execSQL(CREATE_TABLE_APK);
|
||||||
|
clearRepoEtags(db);
|
||||||
|
ensureIndexes(db);
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetTransientPre42(SQLiteDatabase db, int oldVersion) {
|
private void resetTransientPre42(SQLiteDatabase db, int oldVersion) {
|
||||||
@ -753,7 +759,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL("drop table " + AppMetadataTable.NAME);
|
db.execSQL("drop table " + AppMetadataTable.NAME);
|
||||||
db.execSQL("drop table " + ApkTable.NAME);
|
db.execSQL("drop table " + ApkTable.NAME);
|
||||||
clearRepoEtags(db);
|
clearRepoEtags(db);
|
||||||
db.execSQL(CREATE_TABLE_APP);
|
db.execSQL(CREATE_TABLE_APP_METADATA);
|
||||||
db.execSQL(CREATE_TABLE_APK);
|
db.execSQL(CREATE_TABLE_APK);
|
||||||
ensureIndexes(db);
|
ensureIndexes(db);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class TempAppProvider extends AppProvider {
|
|||||||
final SQLiteDatabase db = db();
|
final SQLiteDatabase db = db();
|
||||||
ensureTempTableDetached(db);
|
ensureTempTableDetached(db);
|
||||||
db.execSQL("ATTACH DATABASE ':memory:' AS " + DB);
|
db.execSQL("ATTACH DATABASE ':memory:' AS " + DB);
|
||||||
db.execSQL(DBHelper.CREATE_TABLE_APP.replaceFirst(AppMetadataTable.NAME, DB + "." + getTableName()));
|
db.execSQL(DBHelper.CREATE_TABLE_APP_METADATA.replaceFirst(AppMetadataTable.NAME, DB + "." + getTableName()));
|
||||||
db.execSQL(copyData(AppMetadataTable.Cols.ALL_COLS, AppMetadataTable.NAME, DB + "." + getTableName()));
|
db.execSQL(copyData(AppMetadataTable.Cols.ALL_COLS, AppMetadataTable.NAME, DB + "." + getTableName()));
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_id ON " + getTableName() + " (" + AppMetadataTable.Cols.PACKAGE_NAME + ");");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_id ON " + getTableName() + " (" + AppMetadataTable.Cols.PACKAGE_NAME + ");");
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_upstreamVercode ON " + getTableName() + " (" + AppMetadataTable.Cols.UPSTREAM_VERSION_CODE + ");");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_upstreamVercode ON " + getTableName() + " (" + AppMetadataTable.Cols.UPSTREAM_VERSION_CODE + ");");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user