Reputation: 280
why i am getting this error. I am trying to create session management for signup and login activity.
I got error in this line " pref = new SharedPreferencesUtils(context); "
help me to correct it.
here is my code -
import android.content.Context;
import android.content.SharedPreferences;
import com.google.android.gms.common.util.SharedPreferencesUtils;
public class SessionManagement {
SharedPreferencesUtils pref;
Context context;
public SessionManagement(Context context) {
this.context = context;
pref = new SharedPreferencesUtils(context);
}
public void createLoginSession(String s, String s1, String s2, String s3, String s4, boolean b) {
}
}
Upvotes: 0
Views: 192
Reputation: 3730
This is sample of code from my project , follow these step :
// Call this function where you want to save your data
private void storeCredentials(String email , String password) {
SharedPreferences credentialsPrefs = getSharedPreferences("prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = credentialsPrefs.edit();
editor.putString("email",email);
editor.putString("password",password);
editor.apply();
}
SharedPreferences credentialsPrefs = getSharedPreferences("prefs", Context.MODE_PRIVATE);
String email = credentialsPrefs.getString("email","default-value");
String password = credentialsPrefs.getString("password","default- value");
Upvotes: 2