0

I want to check if an app has been installed on a device before by writing a file into internal storage. Later on when user even re-installs the app, I can check the existence of the file(I'll write the file to some system folder that user won't bother with) to see if user has installed the app before. I just want to know if this is do-able, or is Android against doing things like this? Do I need any permission from user to do this?

I do not want to user any hardware-specific identifier such as IMEI or Android ID. I also don't want to use Instance ID as it will get reset upon re-installation of the app.

1 Answers1

0

You don't need permission to read/write files to the Internal storage of the app. However, once the user uninstall the app, any file stored in the Internal storage of the app is also deleted.

To do what you're trying to do, you would have to write a file to the external storage - which you need permission for.

Have a read through this: https://developer.android.com/training/data-storage/files

Moh Kh
  • 202
  • 3
  • 8
  • Is there something that I can write to that will persist even after uninstallation of the app? Thanks.. – peakpeaktan May 07 '19 at 14:09
  • You can write a file to the external storage and that will persist unless the user manually deletes the file. But you need to request permission to write to the external storage – Moh Kh May 07 '19 at 14:12
  • Requesting extra permission is not going to be a solution for me in this case.. Do you think I can save some value to sharedperference and later on automatically back it up after re-installation of the app? – peakpeaktan May 07 '19 at 14:23
  • You can write to sharedPreferences and keep the data after an uninstall but it will only work on devices running Marshmallow and above: https://stackoverflow.com/questions/35517239/sharedpreferences-are-not-being-cleared-when-i-uninstall – Moh Kh May 07 '19 at 14:26