i am trying to call a method in string from sharedpreference but when i am calling i am facing method invocation getText may produce 'nullpointerexception' warning
public class RetrofitClient {
Sharedpreference sharedpreference;
private final String token = sharedpreference.getTEXT();
following is my sharedpreference code from where i am calling my method getText where i returning a string which is TEXT
public class Sharedpreference {
public static String TEXT = "text";
public static final String Otp = "1234";
SharedPreferences prefs;
SharedPreferences.Editor editor;
public Sharedpreference(Context context){
prefs=context.getSharedPreferences("App_key",0);
editor=prefs.edit();
editor.apply();
}
public void setTEXT(String prize) {
editor.putString(TEXT,prize);
editor.commit();
}
public String getTEXT() {
return prefs.getString(TEXT,"");
}
public void setotp(String otp) {
editor.putString("otp",otp);
editor.commit();
}
public String getotp() {
return prefs.getString("otp","");
}
}