JadeSharedPreference - A light weight library which uses annotation processing to generate codes that let you read and write to SharedPreferences file

Overview

JadeSharedPreference

Android Arsenal CircleCI

A light weight library which uses annotation processing to generate codes that let you read and write to SharedPreferences file.

  • Eliminate the whole SharedPreference boilerplace codes
  • Write less code to configure JadeSharedPreference
  • Save multiple values to SharedPreferences at onces
  • Read from SharedPreferences using just annotations @Read...)
  • Listen to value changes in real-time
  • Read/Write Preference data anywhere in your app

No one like writing lot of codes just to do a simple task. I mean, who does this:

    val sp: SharedPreference = getSharedPreferences("coconut_head", Context.MODE_PRIVATE)
    val value: String? =sp.getString("key", null)

When you can achieve same thing with less line of codes. Such as this:

    @ReadString("key")
    val value: String?= null

What's new in version 1.3.0

  • Bug fixes
  • Support for Preference file

Usage

class InecBox @SharedPref("key") @Preference constructor(context: Context) {

    val TAG: String = "InecBox"
	
    @ReadString("ballot")
    var ballotPaper: String? = null
    
    
    @ReadPrefString("pref_ballot")
    var fakeBallot: String? = null

    //Setup for SharedPreference file
    private var jsp :JadeSharedPreference =JadeSharedPreference.apply(this, context)
    
    //Setup for Preference file
    private var jp :JadeSharedPreference =JadeSharedPreference.preference(this, context)

    fun inecBox() {
        jsp.insert("ballot", "Ballot Paper")
    }
    
    fun readBallot(){
    	Log.d(TAG, ballotPaper)
    }
    
    fun fakeInecBox() {
        jp.insert("pref_ballot", "Fake Ballot Paper")
    }
    
    fun readFakeBallot(){
    	Log.d(TAG, fakeBallot)
    }
    
}

Check the sample project to see more sample usages.

Configuration

Step 1: 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 {
		implementation 'com.github.devmike01.JadeSharedPreference:binder:1.3.0'
		kapt 'com.github.devmike01.JadeSharedPreference:compiler:1.3.0'
	}	

Note: Add apply plugin: 'kotlin-kapt' - if you don't already have it, to your app build.gradle to allow the the processor generates the necessary codes.

License

Copyright 2018 Oladipupo Gbenga

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...
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

The KPy gradle plugin allows you to write Kotlin/Native code and use it from python.

The KPy gradle plugin allows you to write Kotlin/Native code and use it from python.

Android SharedPreferences Helper
Android SharedPreferences Helper

PocketDB Android SharedPreferences Helper This is SharedPreferences Helper like a database noSql. Support AES encryption Latest Version Download depen

Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. It can be done easily, you are just a few steps away from implementing your own badass looking Calendar for your very own project!
Koin Annotations - help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you

The goal of Koin Annotations project is to help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you. The goal is to help developer experience to scale and go fast 🚀 , thanks to Kotlin Compilers.

Order picking with QR codes

Order PiQR Order picking with QR codes Open the project in Android Studio and run. First step was to create a new simple project in Android Studio. Th

Android Application that let users select 2 currencies with the amount to convert
Android Application that let users select 2 currencies with the amount to convert

Currency Converter Android Application that let users select 2 currencies with the amount to convert and have Historical data for 2 currencies of thei

An annotation and Kotlin compiler plugin for enforcing a when statement is exhaustive

An annotation and Kotlin compiler plugin for enforcing a when statement is exhaustive

Annotation based Android lint check generation
Annotation based Android lint check generation

Intervention Annotation based Android lint check generation Generate custom Android lint checks and have lint warn you about code you may be dealing w

Releases(1.3.0)
Owner
Gbenga Oladipupo
Native(Kotlin/Java) Android Developer | Flutter Developer | Python programmer.
Gbenga Oladipupo
Simple and light-weight event dispatcher for Kotlin

KDispatcher is a Kotlin EventDispatcher This is light-weight event dispatcher based on KOTLIN priority: Int? = null to subscribe function for sorting

Alexandr Minkin 63 Oct 3, 2022
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

Jacob Lim 1 Oct 28, 2021
[Android Library] A SharedPreferences helper library to save and fetch the values easily.

Preference Helper A SharedPreferences helper library to save and fetch the values easily. Featured in Use in your project Add this to your module's bu

Naveen T P 13 Apr 4, 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
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
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Carousel Recyclerview Create carousel effect in recyclerview with the CarouselRecyclerview in a simple way. Including in your project Gradle Add below

Jack and phantom 514 Jan 8, 2023
🔴 A non-deterministic finite-state machine for Android & JVM that won't let you down

HAL is a non-deterministic finite-state machine for Android & JVM built with Coroutines StateFlow and LiveData. Why non-deterministic? Because in a no

Adriel Café 73 Nov 28, 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