how to store and retrieve (key,value) kind of data using saved preferences android

后端 未结 5 1873
终归单人心
终归单人心 2021-01-06 18:10

I have a hash map table as below,

HashMap backUpCurency_values = new HashMap();

and i want to

5条回答
  •  無奈伤痛
    2021-01-06 18:47

    You can use SharedPreferences.

    settings = getSharedPreferences(PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    
    //The below step you can repeat to put all the key value pair from the hashmap to the shared preference
    
    editor.putString("Key", Value);
    
    // Commit the edits!
    editor.commit();
    

    And to retrieve later use

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    boolean silent = settings.getString(, );
    

提交回复
热议问题