How to check if an Android application is open for the first time

I wanted to have a popup when the user first opens the application.

How can I check / get the number of times the application has been opened?

Please, help. Many thanks.

+4
source share
1 answer

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

+8
source

Source: https://habr.com/ru/post/911309/


All Articles