I want my application to know if it was installed & started already on the device. Currently, I store a unique user ID key in the shared preferences on the device. Restarting the application loads the user ID from the shared pref and hence, the application knows it was started previously. But after an uninstall and re-install, that shared preferences are gone byebye. Im aware I could write some file in external/internal storage of the device and those will not be removed on uninstall. But is there a more common technique to achieve my requirements? Other applications may read the contact's phone number use it server-sided to determine it, but I dont want to add such personal permissions to my app.
Related
Auto Backup for Apps automatically backs up a user's data from apps that target and run on Android 6.0 (API level 23) or later.
I've a specific SharedPreferences data that I want to automatically back-up, but not all SharedPreferences. Is that possible to do?
Problem: I save an information about user on how much times he has opened application. I'd love to save this number on cloud, because, alot of users nowadays go to Google Play Store and update an existing application following (Uninstall -> Install). Well, as for now, my allowBackup=false, which means, that whenever user uninstalls app, the crucial information about user and his application opening count is lost. If I set allowBackup=true then I keep saving unnesassary data. Is there a possibility to save on the cloud part of SharedPreferences (not everything)? Is there other alternatives?
Is it possible to save some information at the device, if user deletes the application from his device? Something like a key-value (f.e. ("app id","date of installation")) which will not be removed?
Background: we are working on an application, which has an anonymous user for "exploring the app". This user should be removed, if user logs in. We can cover all cases, but not if user deletes the whole application. In iOS you can achieve this, by saving some values in the iOS-Keychain.
Any ideas or workarounds are welcome!
You have to save the data to some external file. So when you want to get the data you can read the data based on the file path.
Is it possible to save some information at the device, if user deletes the application from his device?
You can put stuff out on external storage in a place that will not be automatically deleted when your app is uninstalled (e.g., one of the roots supplied by Environment). However, the user can delete that file whenever the user wants.
Beyond that, there are no options, specifically so apps do not leave cruft behind that builds up and clutters up the user's device.
we are working on an application, which has an anonymous user for "exploring the app". This user should be removed, if user logs in.
It is unclear what this has to do with your original question.
How to check if the app is a fresh installation or a re installation. I want the user to have his history downloaded if its a re-installation like whats app. I thought of writing the user id in the shared preference but that is not possible as the data may get erased once the app is uninstalled. I am already having a folder of my app on the device which is used for image caching and downloading new images, but this is not reliable as the user may delete the folder. What else can I try ???
Obtain the user storage with getExternStorage, then leave a file there that specifies the usage history. The file you save there will survive uninstalls and reinstalls. Of course the user can delete that file but generally they will not, and if you name it properly they will realize it is part of a program.
I'd suggest you integrate with Android's Backup Service.
People switch phone every two years. Some factory reset their device. Some have more than one device. And some share their device with their kids. Linking a user history so that it follows a particular google account is the ideal way to go.
As to your question regarding Facebook integration, I'm afraid I know too little about that topic to be of any help.
I found out the backup can restored the shared preferences after the application been uninstall, just wondering is there anyway to keep SharedPreferences in device even the application have been uninstall in offline mode?
This is done by Google's backup service. If you wanted to do it by yourself.
Several choice for you:
1. Store the data on line by yourself.
2. Store the data on SDCARD
And some more information: uninstall the APK will not cause the data to be removed immediately.
I am developing an Android app. This app stores preferences (user settings) relative to its functioning, such as preferred image quality, etc. etc.. And purchases too.
My question is: How to store these settings in Android in a way that they remain persistent even if the application is removed.
Specifically purchases. I want the user to be able to purchase an in-app feature, uninstall the app, and if he reinstalls the app and presses a "Restore Purchases" button, the previously purchased feature will be restored.
I am currently using Android's SharedPreferences to store these settings. I would like some comment on if this will work for my purpose or not.
If you use shared preferences, it will not work. We can't store data permanently using the shared preferences. The best way is using a web service as a backend.
The short answer for your specific case is to use the "managed by user account" purchase type when you set up in-app billing.
Regarding the general case, your app's SharedPreferences are deleted when your app is uninstalled, so no, this will not work. The only data that is kept around after uninstallation is that stored in a public directory in external storage (usually but not always an SD card). Your app's private directory on external storage is deleted, along with your databases, SharedPreferences, etc. during uninstallation.
It would be in poor form (and not very reliable) to use a public area of external storage to try to save user data for this purpose. The correct solution to the general problem of storing user data across devices or uninstall/reinstall cycles is, as #anoop suggested, to send it to a server.