Is it possible to add an array or object to SharedPreferences on Android

前端 未结 11 1721
别跟我提以往
别跟我提以往 2020-11-22 11:27

I have an ArrayList of objects that have a name and an icon pointer and I want to save it in SharedPreferences. How can I do?

NOTE:

11条回答
  •  孤独总比滥情好
    2020-11-22 12:03

    I loaded an array of waist sizes (already created in my array.xml) into my preferences.xml file with the code below. @array/pant_inch_size is the id of the entire array.

      
    

    This populated the menu with choices from the array. I set the default size as 34, so when the menu pops up, they see size 34 is pre-selected.

提交回复
热议问题