diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-06-04 18:49:01 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-04 18:49:01 +0200 |
commit | fa12643e758aad0bfd70e1f6744761e4befae756 (patch) | |
tree | f7f1f80c9ebfb783175c8d9c5ccd72c785539daf /src/main/java/eu/siacs/conversations/ui | |
parent | c54d30ac003fec40b5263cf9948c20d3163eda7b (diff) |
check database versione before import
* don't import database if backup version is newer than system version
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java | 14 |
1 files changed, 10 insertions, 4 deletions
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 { |