You will need to save data in shared preference when you are developing android applications. Below example show how to develop that functionality.

Save Data in Shared Preferences

SharedPreferences pref = getApplicationContext().getSharedPreferences("user", 0);
SharedPreferences.Editor editor = pref.edit();
editor.putString("userpin", pin.toString());
editor.commit();

Read Data from SharedPreferences

SharedPreferences settings = getSharedPreferences("user", 0);
String userPin = settings.getString("userpin","");

Remember this way is good only for small scale data saving and processing. Other wise you have to use SQL Lite.

2 thoughts on “Save/Read data at shared preference in Android

Leave a Reply

Your email address will not be published. Required fields are marked *

WP Facebook Auto Publish Powered By : XYZScripts.com