My application stores some files that are required for it to run in the data directory of the app
/data/data/com.example.myapp/files/filehere.file
When my application is updated from the market, it is important that I clear the files in the data directory, and update them to the latest ones from the new package that has just been downloaded.
My question is, how do I programatically delete the files in the directory in question?
Alternatively, is there an alternative directory that I can store the files in that are persistent across the lifetime of my application version, but will be cleared once an update is installed?
File file = new File(FILEPATH);
if(file.exists())
file.delete();
As for your last question, my guess is you'll have to control that on your upgrade process. f.e., create a directory for each version and manage the files inside when the user upgrades.
You might be better off using a database wrapped in SQLiteOpenHelper. You can then use the onUpgrade function to detect a new app version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With