Skip to content

Instantly share code, notes, and snippets.

@fm-sys
Last active November 12, 2020 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fm-sys/881458f9359dc711c2b6454d602d5edd to your computer and use it in GitHub Desktop.
Save fm-sys/881458f9359dc711c2b6454d602d5edd to your computer and use it in GitHub Desktop.
[Android] check via SharedPreferences, if it's the very first appstart
public boolean isFirstRun() { // returns true if it's the first start, otherwise false
boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true);
if (isFirstRun){
getSharedPreferences("PREFERENCE", MODE_PRIVATE)
.edit()
.putBoolean("isFirstRun", false)
.apply();
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment