0

I was trying to retrieve list of string but it shows the error.Here are the classes

This is the class to retrive the list of strings

    public List<String> getPrefsEnteredEmails() {
        List<String> emailList;
        if (enteredEmail.contains(PREFS_ENTERED_EMAILS)) {
            String email=enteredEmail.getString(PREFS_ENTERED_EMAILS,null);
            Gson gson=new Gson();
            emailList=gson.fromJson(email, new TypeToken<List<String>>() {
            }.getType());
        } else {
        return null;
        }
        return emailList;     
        }

this is the class where i store the strings

 public void setPrefsEnteredEmails(String  enteredEmail, int resultCode)
 {
    if (resultCode==1){
        List emailList;
        if (getPrefsEnteredEmails()==null){
            emailList=new ArrayList<>();
            emailList.add(enteredEmail);
            enteredEmailEditor.putString(PREFS_ENTERED_EMAILS,enteredEmail).commit();

        }else {
            enteredEmailEditor.putString(PREFS_ENTERED_EMAILS, enteredEmail).commit();
        }
    }else {
        enteredEmailEditor.remove(PREFS_ENTERED_EMAILS).commit();
    }
}
Community
  • 1
  • 1
arps
  • 407
  • 1
  • 3
  • 11

0 Answers0