androidandroid-internal-storage

Can I write to internal storage on Android devices to check if app has installed before on the device?


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.


Solution

  • 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