Skip to content

Instantly share code, notes, and snippets.

@MohammedRashad
Last active November 14, 2016 10:33
Show Gist options
  • Save MohammedRashad/1bd674c69ce0a76613e22edfc3640f84 to your computer and use it in GitHub Desktop.
Save MohammedRashad/1bd674c69ce0a76613e22edfc3640f84 to your computer and use it in GitHub Desktop.
Helper Class for saving values in android using SharedPreferences
package com.dummyname.app;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
public class SharedPreferences{
SharedPreferences spf;
SharedPreferences.Editor edit;
public void save(String key, String value, Context mContext) {
spf = PreferenceManager.getDefaultSharedPreferences(mContext);
edit = spf.edit();
edit.putString(key, value);
edit.commit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment