I want to use a file to store purchased data. Since the app is going to be free and a certain amount of credits are given at the installation. What happens now is that if I uninstall the installation, also the files on the SD card are deleted. So at reinstallation you have your free credits again.
I use the following code:
File file = new File(mContext.getExternalFilesDir(null), FILENAME);
try {
FileOutputStream os = new FileOutputStream(file);
DataOutputStream out = new DataOutputStream(os);
out.writeInt(5); //5 CREDITS TO START
out.close();
if(CreditFileExists()) {
Log.w("ExternalStorageFileCreation", "First Time so give 5 credits");
} else {
Log.e("ExternalStorageFileCreation", "Error in creating CreditFile");
Toast.makeText(mContext, R.string.sdnotavailable, Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
// Unable to create file, likely because external storage is
// not currently mounted.
Log.e("ExternalStorage", "Error writing " + file, e);
Toast.makeText(mContext, R.string.sdnotavailable, Toast.LENGTH_SHORT).show();
}
So the file is saved in this directory getExternalFilesDir(null), apparently that directory is cleaned at uninstallation, anybody any tips for this matter?
Thanks!