Typed Shared Preferences with kotlin

Overview

TypedSharedPreferences

By specifying type parameters for the keys you define, you can avoid typing mistakes when saving to SharedPreferences.

Installation

TBD

Code examples

Define keys with type parameter.

sealed class Keys {
    object Name : Key<String>
    object Age : Key<Int>
    object Birthday : Key<Long>
    object SyncRate : Key<Float>
    object HasIdCard : Key<Boolean>
    object Friends : Key<Set<String>>
}

You can pass key / value pairs as Entry.

val typedSharedPreferences = TypedSharedPreferences(preferences)
typedSharedPreferences.putString(Entry(Keys.Name, "Shinji"))

If you specify a value other than String for Keys.Name, the compiler will tell you an error.
If you specify a key with a non-String parameter (such as Keys.Age) as the parameter for the putString() or getString(), compiler will tell you an error.

You might also like...
A lightweight library to help you navigate in compose with well typed functions.

TypedNavigation A lightweight library to help you navigate in compose with well typed functions. Installation: You can add this library to your projec

Gradle plugin which allows to use typed DSL for generating kubernetes/openshift YAML files

gr8s Gradle plugin which allows using typed DSL for generating kubernetes/openshift YAML files. Based on kuberig Usage import io.github.guai.gr8s.Gene

App that says if the movie you typed in has bazooka or not.

TemBazuca App that says if the movie you typed in has bazooka or not. But... why? The idea for the app came up while I was watching Choque de Cultura

Kotlin-dsl-sample - Preferences project on android

kotlin-dsl-example Sample preferences project on android. How to use val

Find your ideal fitness partners according to your preferences and interact with them whenever you want! All this with no hassle, because there's FitMate! Take timed challenges updated daily, read blogs related to health, and be a part of numerous communities too! During covid times, partner with your FitMate to achieve your fitness goals at home.
Preferences data store example

DataStore Example this example shows how you can use data store to store data in key value pairs and get rid of shared preferences Medium Article: htt

⚙ A beautiful and extensible API for bulding preferences screen
⚙ A beautiful and extensible API for bulding preferences screen

Material Preferences 💻 Installation Add this in app's build.gradle file: implementation 'com.imangazaliev.material-prefs:core:version' implementati

MiHawk  🦅👁️  is simple and secure 🔒 Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences 💽 to store data.
MiHawk 🦅👁️ is simple and secure 🔒 Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences 💽 to store data.

MiHawk MiHawk 🦅 👁️ is simple and secure 🔒 Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack

Shared ViewModel in Kotlin Multiplatform

multiplatform-viewmodel 🗳 Create shared ViewModel's for shared business logic using our ViewModel base class. Features Uses Jetpack ViewModel on Andr

Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI
Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI

KMMNewsAPP There are two branches Main News App Main The main branch is a complete template that you can clone and use to build the awesome app that y

🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture

GithubSearchKMM Github Repos Search - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Depend

A simple and customizable Android full-screen image viewer with shared image transition support,
A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures

Stfalcon ImageViewer A simple and customizable full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" g

Open-source telematics app for Android. The application is suitable for UBI (Usage-based insurance), shared mobility, transportation, safe driving, tracking, family trackers, drive-coach, and other driving mobile applications
Open-source telematics app for Android. The application is suitable for UBI (Usage-based insurance), shared mobility, transportation, safe driving, tracking, family trackers, drive-coach, and other driving mobile applications

TelematicsApp-Android with Firebase© integration Description This Telematics App is created by DATA MOTION PTE. LTD. and is distributed free of charge

🍭🚀💗  Tutorials about animations with Animators, Animated Vector Drawables, Shared Transitions, and more
🍭🚀💗 Tutorials about animations with Animators, Animated Vector Drawables, Shared Transitions, and more

🍭🚀💗 Tutorials about animations with Animators, Animated Vector Drawables, Shared Transitions, and more

D-KMP Architecture official sample: it uses a shared KMP ViewModel and Navigation for Compose and SwiftUI apps.
D-KMP Architecture official sample: it uses a shared KMP ViewModel and Navigation for Compose and SwiftUI apps.

D-KMP architecture - official sample This is the official sample of the D-KMP architecture, presenting a simple master/detail app, for Android, iOS an

Clean MVVM with eliminating the usage of context from view models by introducing hilt for DI and sealed classes for displaying Errors in views using shared flows (one time event), and Stateflow for data

Clean ViewModel with Sealed Classes Following are the purposes of this repo Showing how you can remove the need of context in ViewModels. I. By using

Clean MVVM with eliminating the usage of context from view models by introducing hilt for DI and sealed classes for displaying Errors in views using shared flows (one time event), and Stateflow for data

Clean ViewModel with Sealed Classes Following are the purposes of this repo Showing how you can remove the need of context in ViewModels. I. By using

InterAcao: tasks shared between people in a condominium or the same community
InterAcao: tasks shared between people in a condominium or the same community

Projeto Integrador - Generation Brasil 🤝 🤝 Interação 🤜 🤛 Sobre • Funcionalidades • Implementações futuras • Layout • Como executar • Tecnologias •

Android practice shared ViewModel

Cupcake app This app contains an order flow for cupcakes with options for quantity, flavor, and pickup date. The order details get displayed on an ord

Releases(0.0.2)
Owner
null
Android Shared preference wrapper than encrypts the values of Shared Preferences. It's not bullet proof security but rather a quick win for incrementally making your android app more secure.

Secure-preferences - Deprecated Please use EncryptedSharedPreferences from androidx.security in preferenced to secure-preference. (There are no active

Scott Alexander-Bown 1.5k Dec 24, 2022
A library for debugging android databases and shared preferences - Make Debugging Great Again

Android Debug Database Android Debug Database is a powerful library for debugging databases and shared preferences in Android applications Android Deb

AMIT SHEKHAR 8.1k Dec 29, 2022
A library for reading Shared Preferences and Database values within the application.

AppDataReader A library for reading and writing Shared Preferences and Database values of the application within the device. Advantages of using this

Anshul Jain 124 Nov 25, 2022
Secure Preference Manager for android. It uses various Encryption to protect your application's Shared Preferences.

Secure-Pref-Manager ##Secure Preference Manager is a simple Library to help you protect your Shared Preferences. Secure Preference Manager for android

Prashant Solanki 72 Nov 25, 2022
Reactor is key value database and is a great alternative to Shared Preferences.

Reactor Reactor is a fast and secure key-value library for Android, and has an embedded database based on the JSON structure and is a great alternativ

mr amir abbas 37 Oct 30, 2022
Aplicación Android para comprender como funciona el listado y las shared preferences

READ.ME Este proyecto tiene como finalidad explicar como se debe utilizar un RecyclerView con una vista bindeada a este. En el proyecto se puede ver c

Carlos Muñoz Bustamante 4 Apr 12, 2022
Astha Nayak 4 Oct 10, 2022
Onboarding sample project with view pager & shared preferences

Onboarding Sample Project When the application is first downloaded, we go to onboarding from the splash screen. We keep the information that onboardin

Feyza Ürkut 2 Jun 29, 2022
TinyDB Android Shared Preferences Turbo Turkce

TinyDB--Android-Shared-Preferences-Turbo-Turkce Bu sınıf, bir satır kod ile SharedPreferences çağrılarını ve daha fazlasını gerçekleştirmenizi sağlar.

Mehmet Abak 2 Nov 6, 2022
Androids EditText that animates the typed text. EditText is extended to create AnimatedEditText and a PinEntryEditText.

AnimatedEditText for Android This repository contains AnimatedEditText and TextDrawable all of which extend the behaviour of EditText and implement fe

Ali Muzaffar 439 Nov 29, 2022