Answer the question
In order to leave comments, you need to log in
Error on startup. What is wrong in the code?
public class Settings extends AppCompatActivity {
SharedPreferences sf;
EditText money;
public static final String preference = "pref";
public static final String saveIt = "saveKey";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
money = (EditText) findViewById(R.id.text_input_money);
sf = getSharedPreferences(preference, Context.MODE_PRIVATE);
}
public void save(View view) {
String store = money.getText().toString();
SharedPreferences.Editor editor = sf.edit();
editor.putString(saveIt, store);
editor.commit();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question