Created
March 30, 2016 15:13
-
-
Save mtsahakis/a8b8a65dc4f5af1cb115fe1ccf09ce5b to your computer and use it in GitHub Desktop.
A simple utility class that checks whether an app is started for the first time. If so, it sets a boolean shared preferences value accordingly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.preference.PreferenceManager; | |
public class QueryPreferences { | |
private static final String sIsFirstRun = "IS_FIRST_RUN"; | |
public static boolean isFirstRun(Context context) { | |
boolean result = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(sIsFirstRun, true); | |
if(result) { | |
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(sIsFirstRun, false).apply(); | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment