I have a class with all common functions and there i want to get some of sharedpreferences value. below code getSharedPreference() is giving error.
Here's my code:
public class CommonFunctions {
Context mContext;
SharedPreferences sharedPreferences;
public CommonFunctions(Context context) {
this.mContext = context;
sharedPreferences = getSharedPreference("MyPREFERENCES", MODE_PRIVATE);
}
}
Is there any way to get value in java class?
Use below code;
sharedPreferences = context.getSharedPreference("MyPREFERENCES", MODE_PRIVATE);