Save ArrayList to SharedPreferences

前端 未结 30 3552
野的像风
野的像风 2020-11-21 04:43

I have an ArrayList with custom objects. Each custom object contains a variety of strings and numbers. I need the array to stick around even if the user leaves

30条回答
  •  臣服心动
    2020-11-21 05:00

    Using this object --> TinyDB--Android-Shared-Preferences-Turbo its very simple.

    TinyDB tinydb = new TinyDB(context);
    

    to put

    tinydb.putList("MyUsers", mUsersArray);
    

    to get

    tinydb.getList("MyUsers");
    

    UPDATE

    Some useful examples and troubleshooting might be found here: Android Shared Preference TinyDB putListObject frunction

提交回复
热议问题