I notice that my application data on external storage (ie SD card) is deleted during "adb install -r". Although this is normal for uninstalling (and then install optionally afterwards to notice this), I donβt understand why this happens in case of reinstallation (and therefore for market updates). I could swear this is not always the case.
Referring to http://developer.android.com/guide/topics/data/data-storage.html#filesExternal I specifically use "Access files on external storage" on Android 2.2, but not "Saving files, which should be shared "or" Saving cache files. " Therefore, I write and read data in the files "/ sdcard / Android / data /// somefolder / data". My preferences are sticking.
@Commonsware: the problem is not so much in getExternalFilesDir () IMHO, as I see that my data is written where I expect. He just doesn't stick. I am using ao:
public static File getDefaultDirectory(Context context, String packageName) {
File dir;
if(mActivity_getExternalFilesDir!=null){
dir = invokeGetExternalFilesDir(context, "fortune");
}else if(mEnvironment_getExternalStorageDirectory!=null){
dir = invokeGetExternalStorageDirectory();
dir = new File(dir.getPath() + "/Android/data/" + packageName + "/files/");
}else{
return null;
}
return dir;
}
source
share