MiHawk π¦ ποΈ is simple and secure π Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences π½ to store data.
//In build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
//Include the library in your build.gradle.YOUR_MODULE
dependencies {
implementation 'com.github.nedaluof:MiHawk:1.2.2'
}
/**
* There are two ways to init MiHawk , in both MiHawk must initialized
* before any use of it else RuntimeException will be thrown
* */
MiHawk.init(context)
//OR
MiHawk.Builder(context)
.withPreferenceName("MI_HAWK_PREFS")
.withLoggingEnabled(false)
.withMiLogger(MiLogger Implementation)
.withMiEncryption(MiEncryption Implementation)
.withMiSerializer(MiSerializer Implementation)
.build()
MiHawk.put(key: String, value: T)
- over result block "Higher-order function"
MiHawk.get<T>(key: String, result: (T?) -> Unit)
//OR with default value:
MiHawk.get<T>(key: String, defaultValue: T, result: (T?) -> Unit)
- direct result
MiHawk.get<T>(key: String) : T?
//OR with default value:
MiHawk.get<T>(key: String, defaultValue: T) : T?
MiHawk.contains(key: String, result: (Boolean) -> Unit)
MiHawk.remove(key: String, result: (Boolean) -> Unit)
MiHawk.deleteAll(result: (Boolean) -> Unit)
- Provide heavy unit test.
- Provide simple UI that simulate the inputs to test.
Copyright 2021 Nedal Hasan ABDALLAH (NedaluOf)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific
language governing permissions and limitations under the License.
~ Inspired from Hawk Library. ~