Android - Setting and Fetching a StringSet from SharedPreferences?

后端 未结 2 979
执笔经年
执笔经年 2021-01-17 20:03

Good day, I am building an Android Application. I want to store a set of strings in the Preferences to order to track who used the application based on their log in informat

2条回答
  •  广开言路
    2021-01-17 20:16

    Create an editor Object first :

    SharedPreferences.Editor editor = prefs.edit();
    

    And use the editor object to store and fetch your string set like this :

    editor.putStringSet("List", set);
    editor.apply();
    
    Set fetch = editor.getStringSet("List", null);
    

提交回复
热议问题