How to get value of SharedPreferences android

前端 未结 5 1889
我在风中等你
我在风中等你 2021-01-23 02:41

I\'m trying to use SharedPreferences here is what i do

public void StoreToshared(Object userData){
    SharedPreferences mPrefs = getPreferences(MOD         


        
5条回答
  •  孤街浪徒
    2021-01-23 03:16

    You need to convert the string data from SharedPreferences back to a PoJo using Gson. Simply do this:

    Object userData = new Gson().fromJson(data, Object.class);
    

    I guess that should solve it.

提交回复
热议问题