I have taken CSIPSIMPLE code and repackaged to com.mycompany.appname
The problem is, whenever app is crashed, All values are deleted from Shared preferences.
Why?
My Application is
public class BeemApplication extends Application {
static BeemApplication application = null;
public static SharedPreferences mPref;
public static Editor mEditor;
public BeemApplication() {
}
public static BeemApplication getInstance() {
if(application != null) {
return application;
} else {
return new BeemApplication();
}
}
@Override
public void onCreate() {
super.onCreate();
application = this;
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mEditor = mPref.edit();
}
@Override
public void onTerminate() {
super.onTerminate();
}
}
In Activity I will get them like ,
BeemApplication.mEditor.putString(ctx.getString(R.string.pref_online_number), number).commit();
BeemApplication.mPref.getString(ctx.getString(R.string.pref_online_number), number).commit();