README.md 2,2 КБ
Newer Older
Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Shared Preferences Secure

The library allows keep preferences in the form of key-value pairs with data encryption.

### Features:

- Set/Get Boolean.
- Set/Get Int.
- Set/Get Long.
- Set/Get Float.
- Set/Get Double.
- Set/Get String.
- Set/Get List<String>.
- Check is value exist.
- Save data.
- Clear data.
Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
17

Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
18
19
20
21
22
### Dependency

- `BuildRequires: pkgconfig(qca2-qt5)`
- `PKGCONFIG += qca2-qt5`

Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
### Example

```kotlin
const val keyBool = "keyBool"
const val keyInt = "keyInt"
const val keyLong = "keyLong"
const val keyFloat = "keyFloat"
const val keyDouble = "keyDouble"
const val keyString = "keyString"
const val keyListString = "keyListString"

class AuroraSharedPreferencesSecure {
    fun getBool(): Boolean {
        return SharedPreferencesSecure.getBool(keyBool, false)
    }

    fun getInt(): Int {
        return SharedPreferencesSecure.getInt(keyInt, 0)
    }

    fun getLong(): Long {
        return SharedPreferencesSecure.getLong(keyLong, 0)
    }

    fun getFloat(): Float {
        return SharedPreferencesSecure.getFloat(keyFloat, 0.0f)
    }

    fun getDouble(): Double {
        return SharedPreferencesSecure.getDouble(keyDouble, 0.0)
    }

    fun getString(): String {
        return SharedPreferencesSecure.getString(keyString, "-")
    }

    fun getListString(): List<String> {
        return SharedPreferencesSecure.getListString(keyListString, listOf())
    }

    fun drop() {
        SharedPreferencesSecure.drop()
    }

    fun refreshRandomData() {
        // Set data
        SharedPreferencesSecure.putBool(keyBool, Random.nextBoolean())
        SharedPreferencesSecure.putInt(keyInt, Random.nextInt())
        SharedPreferencesSecure.putLong(keyLong, Random.nextLong())
        SharedPreferencesSecure.putFloat(keyFloat, Random.nextFloat())
        SharedPreferencesSecure.putDouble(keyDouble, Random.nextDouble())
        SharedPreferencesSecure.putString(keyString, listOf("first", "second", "third").random())
        SharedPreferencesSecure.putListString(keyListString, listOf(
            listOf("first1", "second1", "third1"),
            listOf("first2", "second2", "third2"),
            listOf("first3", "second3", "third3"),
        ).random())
        // Save change
        SharedPreferencesSecure.save()
    }
}
```