Hope this will help you,
// Good way to use shared preference is like this
public class AppSharedPreference {
public static final String ABC_APP_SHARED_PREFERENCES = "com.example.bachatgatapp.sharedpreferences"; ///////Agent Details need to store in shared preferences///////
private static final String MOBILE_FILE = "mobfile";
// SET - GET "MOBILE NUMBER" IN SHARED PREFERENCE
public static void setMobileFile(Context context, String value)
{
SharedPreferences preferences = context.getSharedPreferences(ABC_APP_SHARED_PREFERENCES, Context.MODE_PRIVATE);
preferences.edit().putString(MOBILE_FILE, value).commit();
}
public static String getMobileFile(Context context) {
SharedPreferences preferences = context.getSharedPreferences(ABC_APP_SHARED_PREFERENCES, Context.MODE_PRIVATE);
return preferences.getString(MOBILE_FILE, "");
}
// Write this code to save value in shared preference
AppSharedPreference.setMobileFile(this, mobile_number);