I did an app that copy a file in the app data folder, but I need that when I overwrite my app with a new version the data folder must be deleted.
How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit: I misunderstood. So the question is, you want your app to detect that it’s installed a new version, and delete the file?
There’s no way to have the action performed on install, but you can have it performed on the first run of the new version of your application. When it runs, do the following.
3 steps:
-When your app is installed, store a SharedPreference with the current version of your app. You can either hardcode this or pull it from PackageManager using:
-Every time your app starts, check that SharedPreference against the current version of the application. If they match, do nothing.
-If they don’t match, there’s a new version of your app on the device! Delete the file you want to delete, and update the SharedPreference to contain the new version number of your app.