diff options
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r-- | src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java | 2 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index f7a26cf63..f4e138cbe 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -52,7 +52,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { private static DatabaseBackend instance = null; public static final String DATABASE_NAME = "history"; - private static final int DATABASE_VERSION = 27; + public static final int DATABASE_VERSION = 27; private static String CREATE_CONTATCS_STATEMENT = "create table " + Contact.TABLENAME + "(" + Contact.ACCOUNT + " TEXT, " diff --git a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java index 3e35bd48c..56bae7b39 100644 --- a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java @@ -87,11 +87,13 @@ public class WelcomeActivity extends Activity { SQLiteDatabase checkDB = null; String DB_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pix-Art Messenger/.Database/"; String DB_NAME = "Database.bak"; + int DB_Version = DatabaseBackend.DATABASE_VERSION; try { - String myPath = DB_PATH + DB_NAME; - checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); - Log.d(Config.LOGTAG,"Backup found"); + String dbPath = DB_PATH + DB_NAME; + checkDB = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READONLY); + Log.d(Config.LOGTAG, "Backup found: " + checkDB + " Version: " + checkDB.getVersion()); + } catch (SQLiteException e) { //database does't exist yet. } @@ -99,7 +101,11 @@ public class WelcomeActivity extends Activity { if (checkDB != null) { checkDB.close(); } - return checkDB != null ? true : false; + if (checkDB != null && checkDB.getVersion() <= DB_Version) { + return true; + } else { + return false; + } } private void ImportDatabase() throws IOException { |