The Blog

Android: How to execute some code only on first time the application is launched

12 Apr 12

It happens you need to execute some piece of code only on the first time the user start using your app.

Lets say you want to show a quick tutorial to the user just once — Indeed, when the user open your app for the first time.

Well, an easy solution would be to use a SharedPreference to store the info we need to accomplish this “task”.

Below, a snippet with a simple method ( to be included inside your activity class ) that will “solve” the problem.