I have created a new preference which directly extends from CheckboxPreference
. In this class I added a simple new boolean
value. My question now is how I have to store this new value. If a user clicks a normal CheckboxPreference
the value is stored automaticly in the preferences. I want that this happens also with my new value. For this I think I have to overwrite a method but I do not know which of them. Also I have two boolean
values now (checked and my own) so I have to build a logic or something like this with integers because there are four different possibilities with two booleans. So how can I store my two values efficiently and which method do I have to overwrite for this?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You should use
SharedPreference
,which you store value and key pairs. For example key is "colorPreference" and value is "green". It doesn't get deleted even if you close app.//Setting shared preference
//Adding something you want
//Getting value you have stored
//Deleting
key-value
pair if no need anymore//Delete every
key-value
pair inside defaultSharedPreferenceAlso you can use
apply()
instead ofcommit()
which does operations asynchronously in background.