aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-07 19:30:08 +0200
committerAndreas Straub <andy@strb.org>2015-07-07 19:30:08 +0200
commit7cdf2a99465b765027f69ac98302dfaca582d05b (patch)
tree4f086b54e81001b11a85d5b829fd2641f08ef473 /src/main
parent30403a70f25628beb7fce5c5193c0b5f61d31ebd (diff)
Refactor axolotl database recreation
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
index c70ffad2..a3868a1d 100644
--- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -283,14 +283,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
cursor.close();
}
if (oldVersion < 15 && newVersion >= 15) {
- db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.SESSION_TABLENAME);
- db.execSQL(CREATE_SESSIONS_STATEMENT);
- db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.PREKEY_TABLENAME);
- db.execSQL(CREATE_PREKEYS_STATEMENT);
- db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.SIGNED_PREKEY_TABLENAME);
- db.execSQL(CREATE_SIGNED_PREKEYS_STATEMENT);
- db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.IDENTITIES_TABLENAME);
- db.execSQL(CREATE_IDENTITIES_STATEMENT);
+ recreateAxolotlDb();
}
}
@@ -868,4 +861,17 @@ public class DatabaseBackend extends SQLiteOpenHelper {
public void storeOwnIdentityKeyPair(Account account, String name, IdentityKeyPair identityKeyPair) {
storeIdentityKey(account, name, true, Base64.encodeToString(identityKeyPair.serialize(),Base64.DEFAULT));
}
+
+ public void recreateAxolotlDb() {
+ Log.d(Config.LOGTAG, ">>> (RE)CREATING AXOLOTL DATABASE <<<");
+ SQLiteDatabase db = this.getWritableDatabase();
+ db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.SESSION_TABLENAME);
+ db.execSQL(CREATE_SESSIONS_STATEMENT);
+ db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.PREKEY_TABLENAME);
+ db.execSQL(CREATE_PREKEYS_STATEMENT);
+ db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.SIGNED_PREKEY_TABLENAME);
+ db.execSQL(CREATE_SIGNED_PREKEYS_STATEMENT);
+ db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.IDENTITIES_TABLENAME);
+ db.execSQL(CREATE_IDENTITIES_STATEMENT);
+ }
}