how to strore data in shared preferences in table format
Shared preferences = "Key" , "Value" sets.
If we wants to store small amount of data like usernames, passwords then we will go for Shared Preferences.
To store small amount of data there is no need of creation of Database, tables, insertion query and retrieval query --- So better to go for Shared Preferences.
Shared Preferences is to stores small amount of data, where as SQLite3 is to store large amount of data.
Shared preferences works like HashMap in Collections.
Shared preferences data will be stored in xml file. This xml file we can find in the following location.
Go to
Note: When you push anything into emulator "DONT FORGET TO RESTART YOUR EMULATOR". Otherwise the changes will not be effected.
Storing the values into shared preferences
import android.content.SharedPreferences;
SharedPreferences preference;
SharedPreferences.Editor editor;
preference=getApplicationContext().getSharedPreferences("PROFILE", 0);
editor=preference.edit();
editor.putString("MANUALPROFILENAME", newProfileValue);
editor.commit();
For getting the values from the shared preferences
import android.content.SharedPreferences;
SharedPreferences preference;
SharedPreferences.Editor editor;
preference=getBaseContext().getSharedPreferences("PROFILE", 0);
String manualsetunset =preference.getString("MANUALPROFILEENAME", "false");// Here false is default value. If the required string does not found in shared preference, the default value will be stored in the string object.