Reputation: 362
I am working on an app which requires file creation on the first launch. On next launch, I have to check if the file exists. If available then skip some app-specific initializations. This works perfectly for me.
Issue : For Android 7.0 and later and Motorola Devices.
The problem starts when I uninstall the app and again download the app from play store. Now files which are created previously are not getting deleted. So all app-specific initializations are getting skipped.
Please help me with this issue. Thanks in advance.
Upvotes: 1
Views: 493
Reputation: 362
So I got the issue. While creating the file I was using the method
context.getExternalFilesDir(null)
This method gives data folder path which is not getting deleted after uninstalling the app.
Replaced with :
context.getFilesDir()
This resolved my issue. Now all files stored are getting deleted after uninstalling the app.
Thanks for all Answers and comments.
Upvotes: 0
Reputation: 799
Is it possible that on android 7.0 and later you have selected your SD card as the default storage location? This would perhaps explain why your files don't get deleted. Otherwise, if those files exist inside the "App Space" , uninstalling the app should automatically delete them.
Upvotes: 1