Skip to content

Commit

Permalink
tryp to take into account path to internal application data dir on so…
Browse files Browse the repository at this point in the history
…me Samsung devices
  • Loading branch information
mtotschnig committed Jun 3, 2012
1 parent 88a8460 commit 1b348e1
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/org/totschnig/myexpenses/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,24 @@ public void setDatabaseName(String s) {
databaseName = s;
}
public boolean backup() {
File appDir = Utils.requireAppDir();
File appDir, backupPrefFile, sharedPrefFile;
appDir = Utils.requireAppDir();
if (appDir == null)
return false;
if (mSelf.mDbOpenHelper.backup()) {
File backupPrefFile = new File(appDir, BACKUP_PREF_PATH);
File sharedPrefFile = new File("/data/data/" + getPackageName()
+ "/shared_prefs/" + getPackageName() + "_preferences.xml");
backupPrefFile = new File(appDir, BACKUP_PREF_PATH);
//Samsung has special path on some devices
//http://stackoverflow.com/questions/5531289/copy-the-shared-preferences-xml-file-from-data-on-samsung-device-failed
String sharedPrefFileCommon = getPackageName()
+ "/shared_prefs/" + getPackageName() + "_preferences.xml";
sharedPrefFile = new File("/dbdata/databases/" + sharedPrefFileCommon);
if (!sharedPrefFile.exists()) {
sharedPrefFile = new File("/data/data/" + sharedPrefFileCommon);
if (!sharedPrefFile.exists()) {
Log.e("MyExpenses","Unable to determine path to shared preference file");
return false;
}
}
return Utils.copy(sharedPrefFile, backupPrefFile);
} else
return false;
Expand Down

0 comments on commit 1b348e1

Please sign in to comment.