I know that preference operation has upgraded to androidx.preference:preference:1.1.1
I can Code A to read the preference values "signature".
How can I write a new value to the preference values "signature" with androidx.preference:preference:1.1.1 in kotlin?
Code A
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity_context)
val name = sharedPreferences.getString("signature", "")
Use it like the old preference library:
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity_context)
sharedPreferences.edit().putString("signature", value).apply()
Just make sure that you import from:
import androidx.preference.PreferenceManager;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.