How to store json object to shared preferences?

前端 未结 8 1335
栀梦
栀梦 2020-12-21 22:53

I am creating an application,In my app I am getting response and displaing it in custom alert dialog, Till here it works fine, Now what I am trying to do is if user selects

8条回答
  •  再見小時候
    2020-12-21 23:42

    if you want to store the response the better way is to write the content into a file.if you want to store only some values you can do like this

    SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit();
     editor.putString("key_from_json", "String_value_from_json");
     editor.putInt("key_from_json","int_value_from_json");
     editor.commit();
    

提交回复
热议问题