Example Android/Java: Shared Preferences;
Declare variables constants.
private SharedPreferences sharedPreferences;
private SharedPreferences.Editor editorSharedPreferences;
private String KEY="KEY";
Initialize the variables.
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO
sharedPreferences = getSharedPreferences(KEY, Context.MODE_PRIVATE);
editorSharedPreferences = sharedPreferences.edit();
}
editorSharedPreferences.putString(KEY,"TEXT");
editorSharedPreferences.apply();
if (sharedPreferences.contains(KEY)) {
String text = sharedPreferences.getString(KEY, "");
// TODO
}
editorSharedPreferences.remove(KEY);
editorSharedPreferences.commit();
See implementation: code