Android objects persisting library. Natural, NoSQL and hipster.
Save any Java / Kotlin objects in Shared Preferences in natural way.
- NoSQL
- Natural & extremely easy to implement
- Serializing objects to json
- Thread-safe
- Tested
- Using SharedPreferences and Gson under the hood
- Compatible with Kotlin & Java Android projects
Don't waste time and resources implementing SQL db in mobile app. In modern world often all the content is stored on a server side. Whenever your mobile client just needs to fetch and cache the data from server and persist user preferences settings Hipstore is for you.
Hipstore storage is not encrypted and you should not store any sensitive data in it. Hipstore is also not suitable for storing very large amounts of data as all the objects are loaded into memory when deserializing them from SharedPreferences file. It's just a wrapper that allows to save non-primitive objects in SharedPreferences.
To get a Hipstore project into your build:
Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.samiuelson:Hipstore:v1.0.2'
}
Declare entities model classes:
class Person(val name: String, val age: Int, val animals: List<Animal>)
class Animal(val name: String)
class SecretToken(val token: String)
Access EntityStorage<T>
or EntitiesSotage<T>
instance by passing SharedPreferences
instance and java class
in constructor:
val storage: EntitiesStorage<Person> = entitiesStorage(prefs) // for multiple instances storage
or
val storage: EntityStorage<SecretToken> = entityStorage(prefs) // for single instance object storage
Classes above allow to perform CRUD operations.
Once you call EntitiesStorage.add(object: Type)
or EntityStorage.put(object: Type)
object is serialized and stored immediately.
All methods are thread-safe.