Reputation: 3226
Is there anyway to know that when an application is launched for the firsttime? I dont want to use sharedpref because when the user cleardata manually it clears all the data.
Upvotes: 2
Views: 349
Reputation: 43088
Use your own server. Just store the unique android id on your server in the first time user launches your application. But you need internet for this.
Upvotes: 1
Reputation: 5572
That is the point of clearing data, the user may want to tell your app to consider itself freshly installed without having to necessarily uninstall the app. You should not be trying to break that expectation. That said.....
You could create a file on the SD card and check for the existence of that file to determine if your app is being run for the first time.
Do not use the normal openFileOutput() calls in android as that will be cleared when the user clears data as well.
Unless the user wipes all files on the SD card, the file should remain in existence. Also, you can do both, a shared preference and the file and then check for one or the other, just in case.
Upvotes: 1