Android Studio编辑器,putstring和commit错误

时间:2015-04-26 20:51:05

标签: android android-studio

我收到错误:

public void save(View v){
    sharedPreferences.Editor editor =  sharedPreferences.edit();
    editor.putString(nameKey, name.getText().toString());
    editor.putString(phoneKey, phone.getText().toString());
    editor.commit();
    Toast.makeText(this,"data saved",Toast.LENGTH_SHORT).show();

}

我在“Editor”,“putstring”和“commit”上遇到错误。它们突出显示为红色?

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

SharedPreferences.Editor editor = sharedPreferences.edit()

感谢stkent!