In shared preferences how to store string array in android application

后端 未结 3 488
不知归路
不知归路 2020-12-16 08:21

In my application am using list view in base adapter.

when i click the item its id store in shared preferences string array format. how to save multiple item id in s

3条回答
  •  时光说笑
    2020-12-16 08:51

    you can save it as string by ,(comma) seperator and while fetching just use split()

    string toPut="";
    
    toPut += "listItem,";
    

    set toPut in your SharePreference and commit()

    To get the same in array: get prefString from SharePreference

    String[] fetchArray= prefString.split(",");
    

提交回复
热议问题