Android SharedPreferences Helper

Overview

PocketDB

License Bintray Pull request Fcm docs Twitter Github

Android SharedPreferences Helper


This is SharedPreferences Helper like a database noSql. Support AES encryption

Latest Version

Download

Download

dependencies {
    // required coroutine
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8'

    // add this library
    implementation "com.utsman.pocket:pocketdb:$latest-version"
}

Use

Installation

This libray using Koin for Dependencies Injection, you need add this line in Application

class MainApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        Pocket.init(this, "utsmangantenkyah") // 16 digit secure key
    }
}

For existing Koin, you can install koin module after inject context androidContext

class MainApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        startKoin {
            androidContext(this@MainApplication) // required context injection
            Pocket.installKoinModule(this, "utsmangantenkyah") // 16 digit secure key
        }
    }
}

Inserting

Pocket have two type class for inserting, Row and Collection. Row for store single data class apart from collection class, and the Collection for storing any collection class.

Row

I want to insert this data

data class User(val name: String)

val user = User("utsman")

So I inserting it like this

Pocket.row("user").insert("utsman", user)

For retrieve that data, I need default of value, so add default param with defaultOf(data)

val default = defaultOf(User("sarah")) // default

// retrieve key of "utsman" from row of "user"
val data = Pocket.row("user").selectOf("utsman", default)

For need observe changes data, I use flowOf and call from coroutine scope or use .listenOnUi for observing in ui thread

Pocket.row("user")
    .flowOf("utsman", default)
    .listenOnUi { data ->
         // observing data changes here
     }

// or
GlobalScope.launch {
    Pocket.row("user")
        .flowOf("key", default)
        .collect {
            // observing data changes here
        }
}

And I want to remove data row of "utsman"

Pocket.row("user").destroy("utsman")

Or remove all data in row of "user"

Pocket.row("user").destroy()

Collection

For the collection, has similiar function with row. Use defaultCollectionOf() for default data.

Pocket.collection("users")...

Table of function

Function Row Collection
insert yes yes
insertAll no yes
flowOf yes yes
selectOf yes yes
destroy yes yes
keys yes yes
Copyright 2020 Muhammad Utsman

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.
You might also like...
Oratio Library for Android Studio helps you simplify your Android TTS codes

Oratio Oratio is a library for Android Studio. This library is useful to a number of developers who are currently making apps using android TTS(Text-T

This is a demo android app representing implementation of SE principles in android app development

Articles Demo This repository contains a sample Android App that shows most popular articles data from NY Times API. This is a sample app that shows h

Android-Boilerplate - Base project for android development with new technology

Android-Boilerplate Base project for android development with new technology, in

Gits-android-extensions - A collection of Kotlin extensions to simplify Android development

gits-android-extensions A collection of Kotlin extensions to simplify Android de

Android Clean Architecture in Rorty is a sample project that presents modern, approach to Android application development using Kotlin and latest tech-stack.
Android Clean Architecture in Rorty is a sample project that presents modern, approach to Android application development using Kotlin and latest tech-stack.

Android Clean Architecture in Rorty is a sample project that presents modern, approach to Android application development using Kotlin and latest tech-stack.

Android Ptrace Inject for all ABIs and all APIs. Help you inject Shared Library on Android.

Android Ptrace Inject 中文可以参考我的注释内容进行理解 我写的注释相对来说比较全面了 How to build Make sure you have CMake and Ninja in your PATH Edit CMakeLists.txt. Set ANDROID_ND

Pleasant Android application development
Pleasant Android application development

⚠️ Anko is deprecated. Please see this page for more information. Anko is a Kotlin library which makes Android application development faster and easi

YouTube Player library for Android and Chromecast, stable and customizable.
YouTube Player library for Android and Chromecast, stable and customizable.

android-youtube-player android-youtube-player is a stable and customizable open source YouTube player for Android. It provides a simple View that can

A highly customizable calendar library for Android, powered by RecyclerView.
A highly customizable calendar library for Android, powered by RecyclerView.

CalendarView A highly customizable calendar library for Android, powered by RecyclerView. With this library, your calendar will look however you want

Owner
Muhammad Utsman
Dulu nya ganteng
Muhammad Utsman
A Kotlin library for reactive and boilerplate-free SharedPreferences in Android

KPreferences A Kotlin library for reactive and boilerplate-free Shared Preferences in Android. With KPreferences you can use Kotlin's marvelous delega

Mohamad Amin Mohamadi 19 Dec 16, 2020
The most complete and powerful data-binding library and persistence infra for Kotlin 1.3, Android & Splitties Views DSL, JavaFX & TornadoFX, JSON, JDBC & SQLite, SharedPreferences.

Lychee (ex. reactive-properties) Lychee is a library to rule all the data. ToC Approach to declaring data Properties Other data-binding libraries Prop

Mike 112 Dec 9, 2022
Easy lightweight SharedPreferences library for Android in Kotlin using delegated properties

Easy lightweight SharedPreferences library for Android in Kotlin using delegated properties Idea Delegated properties in Kotlin allow you to execute a

null 25 Dec 27, 2022
Android Library to make SharedPreferences usage easier.

KotlinPreferences Kotlin Android Library, that makes preference usage simple and fun. KotlinPreferences now have a brother. With KotlinPreferences, yo

Marcin Moskała 50 Nov 6, 2022
Kotpref - Android SharedPreferences delegation library for Kotlin

Kotpref Android SharedPreference delegation for Kotlin. Install repositories { mavenCentral() } dependencies { // core implementation 'co

Takao Chiba 684 Dec 22, 2022
Adapter library for SharedPreferences

EasyPrefs Adapter library for SharedPreferences which reduces boilerplate needed to store simple data, but open enough to not interfere with your own

Kacper Wojciechowski 6 Nov 23, 2021
TensorFlow Lite Helper for Android to help getting started with TesnorFlow.

TensorFlow Lite Helper for Android This library helps with getting started with TensorFlow Lite on Android. Inspired by TensorFlow Lite Android image

Ahmed Gamal 26 Nov 19, 2022
AppCode helper for Kotlin/Native and Xcode

Kotlin Xcode compatibility Gradle plugin The plugin is used by AppCode to set up Kotlin/Native project along with Xcode Sources A multi-build sample w

Kotlin 21 Oct 23, 2022
Android MVVM framework write in kotlin, develop Android has never been so fun.

KBinding 中文版 Android MVVM framework write in kotlin, base on anko, simple but powerful. It depends on my another project AutoAdapter(A library for sim

Benny 413 Dec 5, 2022
Klimatic is an android app built using Kotlin. It try to showcase all the latest technologies used in android.

Klimatic Klimatic is an android app built using Kotlin. It try to showcase all the latest technologies used in android. Built using Android Architectu

Shivam Satija 34 Oct 11, 2022