I know how to save string from EditTexts on android but my problem is: I need to save the number of hours someone worked…
This is a section of the code I have done… There is an error on the toInt method.
try {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("Hours",edit_hours.getText().toInt());
editor.commit();
trying_to_save.setText("SAVED!");
}
catch (Exception e) {
trying_to_save.setText("I crashed");
}
Could you help me with my problem?
Thanks Michael!
Okay I’m not aware there is a toInt() method in Android?
Try this: