Android SharedPreference


Author: yifei / Created: April 4, 2018, 2:01 p.m. / Modified: April 4, 2018, 10:01 p.m. / Edit

用来在应用中存储键值对配置

context.getSharedPreferences("prefName", Context.MODE_PRIVATE) get SharedPreferecnes instance sharedPref.getXXX("keyName", defaultValue) get value from SharedPreferences sharedPref.edit() get editor(SharedPreference.Editor) editor.putXXX("key-name", value) put value editor.commit() commit the changes


评论区