mirror of
https://github.com/moparisthebest/android-app
synced 2024-12-24 07:28:51 -05:00
wipe database after update from versions < 9
This commit is contained in:
parent
a71a0a7bd8
commit
f30b04ac2e
@ -53,6 +53,7 @@ import android.net.NetworkInfo;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
@ -150,6 +151,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
checkAndHandleAfterUpdate();
|
||||||
|
|
||||||
btnSync = (Button)findViewById(R.id.btnSync);
|
btnSync = (Button)findViewById(R.id.btnSync);
|
||||||
btnSync.setOnClickListener(new OnClickListener() {
|
btnSync.setOnClickListener(new OnClickListener() {
|
||||||
@ -196,7 +198,28 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkAndHandleAfterUpdate() {
|
||||||
|
SharedPreferences pref = getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
|
||||||
|
if (pref.getInt("update_checker",0) < 9) {
|
||||||
|
// Wipe Database, because we now save HTML content instead of plain text
|
||||||
|
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
|
||||||
|
database = helper.getReadableDatabase();
|
||||||
|
helper.truncateTables(database);
|
||||||
|
showToast("Update: Wiped Database. Please synchronize.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int versionCode;
|
||||||
|
try {
|
||||||
|
versionCode = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionCode;
|
||||||
|
} catch (Exception e) {
|
||||||
|
versionCode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pref.edit().putInt("update_checker", versionCode).commit();
|
||||||
|
}
|
||||||
|
|
||||||
private void getSettings(){
|
private void getSettings(){
|
||||||
settings = getSharedPreferences(PREFS_NAME, 0);
|
settings = getSharedPreferences(PREFS_NAME, 0);
|
||||||
pocheUrl = settings.getString("pocheUrl", "http://");
|
pocheUrl = settings.getString("pocheUrl", "http://");
|
||||||
|
Loading…
Reference in New Issue
Block a user