Remove superfluous transactions

SQLiteOpenHelper already wraps onCreate and onUpgrade in a transaction.
This commit is contained in:
Henrik Tunedal 2011-02-26 16:54:05 +01:00
parent d65a31e2c5
commit 1b99e0e063
2 changed files with 16 additions and 27 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
local.properties local.properties
bin/* bin/*
proguard.cfg proguard.cfg
*~

View File

@ -246,37 +246,25 @@ public class DB {
@Override @Override
public void onCreate(SQLiteDatabase db) { public void onCreate(SQLiteDatabase db) {
db.beginTransaction(); db.execSQL(CREATE_TABLE_REPO);
try { db.execSQL(CREATE_TABLE_APP);
db.execSQL(CREATE_TABLE_REPO); db.execSQL(CREATE_TABLE_APK);
db.execSQL(CREATE_TABLE_APP); onUpgrade(db, 1, DB_UPGRADES.length + 1);
db.execSQL(CREATE_TABLE_APK); ContentValues values = new ContentValues();
onUpgrade(db, 1, DB_UPGRADES.length + 1); values.put("address",
ContentValues values = new ContentValues(); mContext.getString(R.string.default_repo_address));
values.put("address", values.put("pubkey",
mContext.getString(R.string.default_repo_address)); mContext.getString(R.string.default_repo_pubkey));
values.put("pubkey", values.put("inuse", 1);
mContext.getString(R.string.default_repo_pubkey)); values.put("priority", 10);
values.put("inuse", 1); db.insert(TABLE_REPO, null, values);
values.put("priority", 10);
db.insert(TABLE_REPO, null, values);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
} }
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.beginTransaction(); for (int v = oldVersion + 1; v <= newVersion; v++)
try { for (int i = 0; i < DB_UPGRADES[v - 2].length; i++)
for (int v = oldVersion + 1; v <= newVersion; v++) db.execSQL(DB_UPGRADES[v - 2][i]);
for (int i = 0; i < DB_UPGRADES[v - 2].length; i++)
db.execSQL(DB_UPGRADES[v - 2][i]);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
} }
} }