Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.samiuelson:Hipstore:1.0.4'
}
dependencies {
implementation("com.github.samiuelson:Hipstore:1.0.4")
}
<dependency>
<groupId>com.github.samiuelson</groupId>
<artifactId>Hipstore</artifactId>
<version>1.0.4</version>
</dependency>
libraryDependencies += "com.github.samiuelson" % "Hipstore" % "1.0.4"
:dependencies [[com.github.samiuelson/Hipstore "1.0.4"]]
Android objects persisting library. Natural, NoSQL and hipster.
Save any Java / Kotlin objects in Shared Preferences in natural way.
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.