When the application starts, during the onCreate()
method, you can check if the SharedPreference exists. If this is not the case, this application is launched for the first time. Then create a SharedPreference. Therefore, every subsequent moment the application starts, the value will already be set, and you will find out that it was not launched for the first time.
Read more about reading and setting SharedPreferences in the documentation: http://developer.android.com/guide/topics/data/data-storage.html#pref
source share