I need to call a method (or start an activity, or something else) that will update a file containing data the app needs.
But I want it to be done only once, when the app is first installed; because after I will handle the update of the file myself.
Please how can it be done?
Thanks for any suggestion
Create a launcher activity that loads when your app starts. Have it check for a value (such as firstStartUp) in SharedPreferences (http://developer.android.com/guide/topics/data/data-storage.html#pref) . The first time you ever run the app this value will not exist and you can update your data. After your data is updated set the value in shared preferences so that your app finds it the next time it launches and will not attempt to update the data again.
You could do it by, in your main activities onCreate method, checking your shared prefereces file for any arbitary boolean that you pick the name of. On your first launch this won't be there so you can then call your method and set your boolean to true. This means on the next start of your app this value would be true and the call to your function can be skipped.
You can do it by using
SharedPrefrences
. Look this:to do something only once in app you need something like this :