If loadSavedData is activated before any(first) saving, encounter following error message "com.google.gson.JsonNull cannot be cast to com.google.gson.JsonObject"
I've tried to fix but I couldn't...
Below is a problematic part
private void loadSavedData(){
timetable.removeAll();
SharedPreferences mPref =
PreferenceManager.getDefaultSharedPreferences(this);
String savedData = mPref.getString("timetable_demo1","");
if(savedData == null && savedData.equals("")) return;
timetable.load(savedData);
Toast.makeText(this,"loaded!",Toast.LENGTH_SHORT).show();
}
How can I skip loading-saved-data if savedData is null (initially operated. before the first saving something).. even though loadSavedData is activated in the above statement? (by adjust/refine the if statement.
No error under activating "loadSavedData" is required even though no data is saved before.
Aucun commentaire:
Enregistrer un commentaire