SharedPreference Library to save all types including your custom types and observe them if need be.

Related tags

Utility EasyPref
Overview

GitHub release (latest by date) GitHub top language GitHub all releases Twitter Follow

EasyPref

Observable EasyPrefLib

Description:

A SharedPreference Library that can be used to store all types including your custom classes and observe them too if needed.


Features:

  • Easily store primitive types
  • Easily store custom classes
  • Easily observe primitive or custom classes

Setup.

To get a Git project into your build:

  1. Add the JitPack repository to you root build.gradle at the end of repositories:
allprojects {
    repositories {
	...
	maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency
dependencies {
    implementation 'com.github.EhmaUgbogo:EasyPref:1.0.1'
}

Usage

  1. Initialize EasyPref in your application class or MainActivity
  EasyPref.initialize(this) // If setup in your application class
  EasyPref.initialize(application) // If setup in MainActivity
  1. Use as needed
  EasyPref.hasKey(key)

  // Store primitive types

  EasyPref.putBoolean(key, boolValue)
  EasyPref.getBoolean(key)  // ... Same for Strings, Int, etc 
  
  
  // Store custom types
  
  EasyPref.putObject(OBJ_KEY, yourData)
  EasyPref.getObject(OBJ_KEY, YourData::class.java)
  
  1. Observe as needed
  
  EasyPref.observeBoolean(key).observe(this@MainActivity) {
       // your code here
  }
  
  // observe custom types - returns (PrefObjectHolder)
  
  EasyPref.observeObject(OBJ_KEY, YourData::class.java).observe(viewLifecycleOwner) {
      it.value?.let { yourData -> showSnackBar("$yourData Observed") }
  }
 
  

Licence

MIT Licence

Copyright (c) [2021] Ehma Ugbogo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Author Info

@EhmaUgbogo

Back To The Top

You might also like...
High level parsing to ensure your input is in the right shape and satisfies all constraints that business logic requires.

Parsix High level parsing to ensure your input is in the right shape and satisfies all constraints that business logic requires. It is highly inspired

Kindling - A standalone collection of utilities to help Ignition users. Features various tools to help work with Ignition's custom data export formats Provides custom lint rules developed by Bottle Rocket Studios to help keep our code cleaner
Provides custom lint rules developed by Bottle Rocket Studios to help keep our code cleaner

Provides custom lint rules developed by Bottle Rocket Studios to help keep our code cleaner, detect and mitigate possible security issues, and allow us to write rules around best practices and usage as necessary in the future

Android library to easily serialize and cache your objects to disk using key/value pairs.

Deprecated This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to

Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app
Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app

DroidMVP About DroidMVP is a small Android library to help you incorporate the MVP pattern along with Passive View and Presentation Model (yes, those

A library to quickly and easily enable multiple monitoring & support platforms for your mobile apps

You have a small team. Setting up crash reporting tools, event tracking tools, and log management services is not what you want to spend your hours do

compaKTset is a small library aimed at providing you with the most memory efficient Set implementation for any particular data type of your choosing.

compaKTset is a small library aimed at providing you with the most memory efficient Set implementation for any particular data type of your choosing.

A beautiful set of predefined colors and a set of color methods to make your Android development life easier.
A beautiful set of predefined colors and a set of color methods to make your Android development life easier.

Colours is a port of the Colours Library for iOS made by my good friend Ben Gordon. You can find that project here. Installation Maven Central Colours

[] Define and render UI specs on top of your Android UI
[] Define and render UI specs on top of your Android UI

dspec A simple way to define and render UI specs on top of your Android UI. Usage Enclose the target UI with a DesignSpecFrameLayout, usually the root

Releases(1.0.2)
  • 1.0.2(Jun 30, 2021)

  • 1.0.1(Jun 1, 2021)

    EasyPref is now reactive also i.e you can observe any key and listen for its value. Also included Double put and get functions. Opened up default param to user choice. Throws PrefException on Type mismatch + other update

    Source code(tar.gz)
    Source code(zip)
  • 1.0(May 30, 2021)

Owner
Ehma Ugbogo
Android Java Kotlin Programmer
Ehma Ugbogo
🐫🐍🍢🅿 Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case

KaseChange Multiplatform Kotlin library to convert strings between various case formats Supported Case Formats SCREAMING_SNAKE_CASE snake_case PascalC

PearX Team 67 Dec 30, 2022
TSBattery a new way to save your battery avoid cancer apps hacker it.

TSBattery TSBattery a new way to save your battery avoid cancer apps hacker it. TSBattery 是一个旨在使 QQ、TIM 变得更省电的开源 Xposed 模块 Get startted 此模块支持原生 Xposed

Fankesyooni 375 Jan 2, 2023
adds an option to the Android Sharesheet that allows you to save files to your device.

Save On Device adds an option to the Android Sharesheet that allows you to save files to your device. Download Get the app from the Google Play Store

null 24 Nov 29, 2022
A small library which will save you from writing the same intent creation code again and again for the most simple tasks

Android Intents A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myse

MarvinLabs 420 Nov 20, 2022
A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

Wesley Lin 134 Nov 25, 2022
Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.

PrivacyStreams PrivacyStreams is an Android library for easy and privacy-friendly personal data access and processing. It offers a functional programm

null 269 Dec 1, 2022
Matches incoming and/or outgoing text messages against set rules and sends them over to webhook.

Textmatic If you ever wanted a tool to simply push the SMS (or text messages) from your phone to somewhere remote, this is it. This app matches all in

Float 2 Jan 7, 2022
XClipper is a clipboard manager for Windows & Android which helps to track clipboard activities and makes it easier to interact with them.

XClipper XClipper is a clipboard manager for Windows & Android which helps to track clipboard activities and makes it easier to interact with them ❤️

Kaustubh Patange 134 Dec 31, 2022
A collection of Android build scripts for various third-party libraries and the tooling to build them

ndkports A collection of Android build scripts for various third-party libraries and the tooling to build them. If you're an Android app developer loo

reSIProcate project 0 Jan 17, 2022
Preference wrappers for primitive types for Android

Typed Preferences This library for Android provides classes which allow to store and retrieve settings from the preferences. There is an individual cl

Tobias Preuss 189 Nov 25, 2022