All Projects → BoD → Android Prefs

BoD / Android Prefs

Licence: apache-2.0
Android preferences for WINNERS!

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Prefs

Easyandroid
一系列简单、轻量、方便的Android开发工具集合(持续更新中),包括Android动态权限、SharedPreferences、反射、日志、Toast、Bundle、MVP、线程池、Html、图文混排、蒙层引导、拍照、图库选择等
Stars: ✭ 1,039 (+467.76%)
Mutual labels:  sharedpreferences
React Native Encrypted Storage
React Native wrapper around SharedPreferences and Keychain to provide a secure alternative to Async Storage
Stars: ✭ 110 (-39.89%)
Mutual labels:  sharedpreferences
Bulldog
Android library to simplify reading and writing to SharedPreferences, never write code like this anymore prefs.edit().putString("someKey","someString").apply()
Stars: ✭ 133 (-27.32%)
Mutual labels:  sharedpreferences
Secure Pref Manager
Secure Preference Manager for android. It uses various Encryption to protect your application's Shared Preferences.
Stars: ✭ 75 (-59.02%)
Mutual labels:  sharedpreferences
Contacts
A flutter project with Implementation of a Contacts app in 4 ways (API, Custom, Preferences and Sqflite).
Stars: ✭ 100 (-45.36%)
Mutual labels:  sharedpreferences
Secure Preferences
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.
Stars: ✭ 1,527 (+734.43%)
Mutual labels:  sharedpreferences
Easypreferences
This class simplifies calls to SharedPreferences in a line of code. It can also do more like: saving a list of strings, integers and saving images. All in 1 line of code!
Stars: ✭ 34 (-81.42%)
Mutual labels:  sharedpreferences
Kau
An extensive collection of Kotlin Android Utils
Stars: ✭ 182 (-0.55%)
Mutual labels:  sharedpreferences
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (-39.89%)
Mutual labels:  sharedpreferences
Android Remote Debugger
A library for remote logging, database debugging, shared preferences and network requests
Stars: ✭ 132 (-27.87%)
Mutual labels:  sharedpreferences
Multiplatform Preferences
Kotlin Multi Platform Preferences, for android an ios : SharedPreferences & NSUserDefault
Stars: ✭ 76 (-58.47%)
Mutual labels:  sharedpreferences
Sharedchamber
Android Secure SharedPreferences Using Facebook Conceal Encryption
Stars: ✭ 96 (-47.54%)
Mutual labels:  sharedpreferences
Prefs
Simple Android SharedPreferences wrapper.
Stars: ✭ 125 (-31.69%)
Mutual labels:  sharedpreferences
Easysp
A SharedPreferences wrapper that has a fluent interface to store data
Stars: ✭ 75 (-59.02%)
Mutual labels:  sharedpreferences
React Native Default Preference
Use SharedPreference (Android) and UserDefaults (iOS) with React Native over a unified interface
Stars: ✭ 170 (-7.1%)
Mutual labels:  sharedpreferences
Android Debug Database
A library for debugging android databases and shared preferences - Make Debugging Great Again
Stars: ✭ 7,946 (+4242.08%)
Mutual labels:  sharedpreferences
Movieapp
🎬 MovieApp is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Modularization, BLoC, Dependency Injection, Dynamic Theme, Cache, Shimmer, Testing, Flavor, CI/CD, etc.
Stars: ✭ 117 (-36.07%)
Mutual labels:  sharedpreferences
Oksharedprefs
通过注解生成SharedPreferences包装类,解决跨进程数据访问不同步的问题。
Stars: ✭ 183 (+0%)
Mutual labels:  sharedpreferences
Ksprefs
🚀⚡ Kotlin SharedPreferences wrapper & cryptographic preferences android library.
Stars: ✭ 176 (-3.83%)
Mutual labels:  sharedpreferences
Appdatareader
A library for reading Shared Preferences and Database values within the application.
Stars: ✭ 126 (-31.15%)
Mutual labels:  sharedpreferences

Prefs

Android preferences for WINNERS!

Be a winner!

This little tool generates wrappers for your SharedPreferences, so you can benefit from compile time verification and code completion in your IDE. You also get nice singletons for free.

Android Arsenal

Usage

1/ Add the dependencies to your project

dependencies {
    /* ... */
    annotationProcessor 'org.jraf:prefs-compiler:1.4.0' // or kapt if you use Kotlin
    implementation 'org.jraf:prefs:1.4.0'
}

2/ Define your preferences

Use the @Prefs annotation on any plain old Java object. All its (non static) fields will be considered a preference.

For instance:

@Prefs
public class Main {
    /**
     * User login.
     */
    String login;

    /**
     * User password.
     */
    String password;

    @DefaultBoolean(false)
    Boolean isPremium;

    @Name("PREF_AGE")
    Integer age;
}

Currently, the accepted types are:

  • Boolean
  • Float
  • Integer
  • Long
  • String
  • Set<String>

Optionally, use @DefaultXxx and @Name annotations (the default default is null, and the default name is the name of your field).

You can pass a file name and mode (as per [Context.getSharedPreference()](http://developer.android.com/reference/android/content/Context.html#getSharedPreferences(java.lang.String, int))) like this:

@Prefs(fileName = "settings", fileMode = Context.MODE_PRIVATE)

If you don't, PreferenceManager.getDefaultSharedPreferences(Context) will be used.

3/ Be a winner!

A class named <YourClassName>Prefs will be generated in the same package (at compile time). Use it like this:

        MainPrefs mainPrefs = MainPrefs.get(this);

        // Put a single value (apply() is automatically called)
        mainPrefs.putAge(42);

        // Put several values in one transaction
        mainPrefs.edit().putLogin("john").putPassword("p4Ssw0Rd").apply();

        // Check if a value is set
        if (mainPrefs.containsLogin()) doSomething();

        // Remove a value
        mainPrefs.removeAge();
        // Or (this has the same effect)
        mainPrefs.putAge(null);

        // Clear all values!
        mainPrefs.clear();

Bonus 1: in Kotlin you can directly use =:

        // Put a single value (apply() is automatically called)
        mainPrefs.age = 42

Bonus 2: you also get LiveDatas to observe your preferences:

        mainPrefs.loginLiveData.observe(this, Observer {
            Log.d(TAG, "observed login=$it")
        })

Note: currently this is disabled by default (because maybe you don't use LiveData?) - add generateGetLiveData = true to your @Prefs annotation to enabled it.

License

Copyright (C) 2015-present Benoit 'BoD' Lubek ([email protected])

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.

Just to be absolutely clear, this license applies to this program itself, not to the source it will generate!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].