File tree 2 files changed +8
-4
lines changed
app/src/main/java/com/lzx/kvpref
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,16 @@ class MainActivity : AppCompatActivity() {
13
13
14
14
15
15
findViewById<View >(R .id.write).setOnClickListener {
16
- // SpFileConfig.saveWithKey(SpFileConfig::haha, "哈", 13123121)
17
16
SpFileConfig .tagJson.set(" 1343" , " 我是动态key" )
17
+ SpFileConfig .color.set(" 11111" , 10000 )
18
18
Toast .makeText(this @MainActivity, " 写成功" , Toast .LENGTH_SHORT ).show()
19
19
}
20
20
21
21
findViewById<View >(R .id.red).setOnClickListener {
22
- val obj = SpFileConfig .tagJson
23
- val result = obj.get(" 1343" )
24
- Toast .makeText(this @MainActivity, " obj = $obj result = $result " , Toast .LENGTH_SHORT ).show()
22
+ val result = SpFileConfig .tagJson.get(" 1343" )
23
+ val color = SpFileConfig .color.get(" 11111" )
24
+ Toast .makeText(this @MainActivity, " result = $color " , Toast .LENGTH_SHORT )
25
+ .show()
25
26
}
26
27
27
28
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ object SpFileConfig : KvPrefModel("spFileName") {
18
18
19
19
var tagJson2: DynamicKeyPref <String ?> by dynamicKeyPrefNullable()
20
20
private set
21
+
22
+ var color : DynamicKeyPref <Int > by dynamicKeyPref(100 )
23
+ private set
21
24
}
22
25
23
26
class People {
You can’t perform that action at this time.
0 commit comments