Kotlin SharedPreferences - Save ListView items and load them

前端 未结 3 1921
慢半拍i
慢半拍i 2020-12-22 06:36

I have a ListView with items created by

 val values = ArrayList().toMutableList()
 val adapter = ArrayAdapter(this, R.layout.listview_text_col         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 07:19

    The proper way to save ArrayList of String to preferences is:

    .putStringArrayList("test", values)
    

    and get it

    .getStringArrayList("test")
    

提交回复
热议问题