I have created an activity named activity_create_password which will create password for the app when the application is started on the cell for the first time and next time onwards it should show the activity named activity_insert_password. how can I achieve this I am not getting Please Help.
You have to use SharedPreferences
to achieve this, your code should be something like
SharedPreferences prefs = mContext.getSharedPreferences("appName", 0);
SharedPreferences.Editor editor = prefs.edit();
Intent intent;
if (prefs.getBoolean("isInitialAppLaunch", false))
{
intent = new Intent(this, activity_insert_password.class);
startActivity(intent);
}
else
{
//First Time App launched, you are putting isInitialAppLaunch to false and calling create password activity.
editor.putBoolean("isInitialAppLaunch", false);
intent = new Intent(this, activity_create_password.class);
startActivity(intent);
}
You should use the SharedPreferences class to achieve this.
See the below link to use shared preference.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.