mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
extract the 'upgrade database' method. Since K-9 never had a pre-v18 database, I'm inclined to kill it, except it may serve as a useful template for the future
This commit is contained in:
parent
521783ffff
commit
416aafb940
@ -83,6 +83,19 @@ public class LocalStore extends Store {
|
|||||||
}
|
}
|
||||||
mDb = SQLiteDatabase.openOrCreateDatabase(mPath, null);
|
mDb = SQLiteDatabase.openOrCreateDatabase(mPath, null);
|
||||||
if (mDb.getVersion() != DB_VERSION) {
|
if (mDb.getVersion() != DB_VERSION) {
|
||||||
|
doDbUpgrade(mDb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mAttachmentsDir = new File(mPath + "_att");
|
||||||
|
if (!mAttachmentsDir.exists()) {
|
||||||
|
mAttachmentsDir.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void doDbUpgrade ( SQLiteDatabase mDb) {
|
||||||
|
|
||||||
if (mDb.getVersion() < 18) {
|
if (mDb.getVersion() < 18) {
|
||||||
if (Config.LOGV) {
|
if (Config.LOGV) {
|
||||||
Log.v(k9.LOG_TAG, String.format("Upgrading database from %d to %d", mDb
|
Log.v(k9.LOG_TAG, String.format("Upgrading database from %d to %d", mDb
|
||||||
@ -117,11 +130,6 @@ public class LocalStore extends Store {
|
|||||||
throw new Error("Database upgrade failed!");
|
throw new Error("Database upgrade failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mAttachmentsDir = new File(mPath + "_att");
|
|
||||||
if (!mAttachmentsDir.exists()) {
|
|
||||||
mAttachmentsDir.mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Folder getFolder(String name) throws MessagingException {
|
public Folder getFolder(String name) throws MessagingException {
|
||||||
@ -374,7 +382,7 @@ public class LocalStore extends Store {
|
|||||||
}
|
}
|
||||||
mDb.execSQL("INSERT INTO folders (name, visible_limit) VALUES (?, ?)", new Object[] {
|
mDb.execSQL("INSERT INTO folders (name, visible_limit) VALUES (?, ?)", new Object[] {
|
||||||
mName,
|
mName,
|
||||||
25
|
k9.DEFAULT_VISIBLE_LIMIT
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user