1

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.

Viktor Yakunin
  • 2,927
  • 3
  • 24
  • 39
Rahul
  • 352
  • 1
  • 4
  • 17
  • `are not getting deleted. ` Do you mean: "those files appear not to be deleted when the app was uninstalled"? Please provide full path of their storage location. – greenapps Mar 07 '18 at 12:26

2 Answers2

1

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.

0

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.

Rahul
  • 352
  • 1
  • 4
  • 17