- Like simple NoSQL database
- Supports customizable serialization (gson,moshi... your choice)
- Supports customizable encryption
- No external dependencies¹
- Requires simple NoSQL implementation²
¹ Core features does not require dependencies ² Simple Storage works like a layer above others type of storage
As an Android developer, Hawk is outdated and contains external outdated libraries.
-
Include maven central as repository
-
Simple storage for Android:
dependencies {
⋮
implementation "br.dev.dig.storage:simple-android:${lastest_version}"
⋮
}
- Creating storage:
private fun createStorage(): Storage {
val builder = StorageSimpleAndroidBuilder()
// Hardcoded random string
builder.masterKey("123456")
// Using SharedPreferences file `local`
builder.preferences(getSharedPreferences("local", Context.MODE_PRIVATE))
return builder.build()
}
- Use
Storage
instance:
val storage = createStorage()
val name = storage.get("name", String::class.java)
// OR
val name = storage.get<String>("name")
val age = storage.get("name", Int::class.java)
// OR
val age = storage.get<Int>("name")
For java users, there is StoragePrimitiveWrapper
to provide methods to mimic kotlin style.
Every update in whatever operation of the Storage, old content will be unrecognizable by new configuration, then you need a migration.
Since key can be hashed (normal mode), there is no automatic way to migrate, unless you known every key used.
There is StorageMigration
from br.dev.dig.storage:migration
to migrate Storages to a new one, on demand. Just provide the new storage, alongside with olders. Also can be used to migrate your current storage library to this new storage library.
- You can use and re-dist freely.
- You can also modify, but only for yourself.
- You can use it as a part of your project, but without modifications in this project.
- You can expand this project creating implementations of each operation interface.