in this post You will show you how to Read , Write and Clear Value form Shared Preferences
Add permission To Manifest AndroidManifest.xml
android.permission.READ_PHONE_STATE
Step 01 : Get Value From SharedPreferences
SharedPreferences settings;
String txtname;
String txtpass;
settings = context.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
txtname = settings.getString("nameKey", null);
txtpass = settings.getString("passKey", null);
Step 02 : Set Value To SharedPreferences
SharedPreferences sharedpreferences;
sharedpreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString("nameKey", n);
editor.putString("passKey", ph);
editor.commit();
Step 03 : Clear Value
SharedPreferences sharedpreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.clear();
editor.commit();
Login system SharedPreferences
Reviewed by Unknown
on
3:15 AM
Rating:
No comments: