El Arsenal de Android – Preferencias

Muñequita es una biblioteca que combina 2 tipos de SharedPreferences en un solo lugar: SharedPreferences – Regular sharedPreferences EncryptedSharedPreferences – Clave cifrada AES256: valor SharedPreferences

Dolly implementa la lógica por ti, solo tienes que usarla.

Requisitos

minSdkVersion 23

Repositorio

Agrega esto a tu raíz build.gradle archivo (no su formulario build.gradle archivo):

allprojects {
 repositories {
  ...
  maven { url "https://jitpack.io" }
 }
}

Adiccion

Agrégalo a tu formulario build.gradle archivo (Nota: la versión debe coincidir con la insignia jitpack anterior)

dependencies {
 implementation 'com.github.Amit7474:Dolly-SharedPreferences:1.0.0'
}

Obtenga la instancia de Dolly:

Dolly dolly = Dolly.getInstance(context);

Empiece a usar Dolly:

dolly.getInt("age", 20, Type.ENCRYPT);

API

putInt(key, value, type)

almacenar los valores de Int.

dolly.putInt("Age", 23, Type.ENCRYPT);
dolly.putInt("Age", 20, Type.NOT_ENCRYPT);

getInt(key, defaultValue, type)

obtener valores Int. defaultValue es opcional! en caso de que no se proporcione y falte la clave se devolverá -1

dolly.getInt("Age", 5, Type.ENCRYPT);
dolly.getInt("Age", Type.NOT_ENCRYPT);

putBoolean(key, value, type)

almacenar valores booleanos.

dolly.putBoolean("isSingle", true, Type.ENCRYPT);
dolly.putBoolean("isSingle", true, Type.NOT_ENCRYPT);

getBoolean(key, defaultValue, type)

obtener valores booleanos. defaultValue es opcional. en caso de que no se proporcione y falte la clave se devolverá false

dolly.getBoolean("isSingle", Type.ENCRYPT);
dolly.getBoolean("isSingle", true, Type.NOT_ENCRYPT);

putFloat(key, value, type)

almacenar valores flotantes.

dolly.putFloat("hight", 6, Type.ENCRYPT);
dolly.putFloat("hight", 8, Type.NOT_ENCRYPT);

getFloat(key, defaultValue, type)

obtener valores flotantes. defaultValue es opcional. en caso de que no se proporcione y falte la clave se devolverá -1

dolly.getFloat("hight", 50, Type.ENCRYPT);
dolly.getFloat("hight", Type.NOT_ENCRYPT);

putLong(key, value, type)

almacenar valores largos.

dolly.putLong("hight", 6, Type.ENCRYPT);
dolly.putLong("hight", 8, Type.NOT_ENCRYPT);

getLong(key, defaultValue, type)

obtener valores largos. defaultValue es opcional. en caso de que no se proporcione y falte la clave se devolverá -1

dolly.getLong("hight", 50, Type.ENCRYPT);
dolly.getLong("hight", Type.NOT_ENCRYPT);

putDouble(key, value, type)

almacenar valores dobles.

dolly.putDouble("length", 6.5, Type.ENCRYPT);
dolly.putDouble("hight",10.0, Type.NOT_ENCRYPT);

getDouble(key, defaultValue, type)

obtener valores dobles. defaultValue es opcional. en caso de que no se proporcione y falte la clave se devolverá -1

dolly.getDouble("hight", 50, Type.ENCRYPT);
dolly.getDouble("hight", Type.NOT_ENCRYPT);

putString(key, value, type)

almacenar valores de cadena.

dolly.putString("name", "Dani", Type.ENCRYPT);
dolly.putString("name","Dani", Type.NOT_ENCRYPT);

getString(key, defaultValue, type)

obtener valores de cadena. defaultValue es opcional. en caso de que no se proporcione y falte la clave se devolverá "null"

dolly.getString("hight", "null", Type.ENCRYPT);
dolly.getString("hight", Type.NOT_ENCRYPT);

putStringSet(key, value, type)

almacenar los valores del conjunto de cadenas.

Set<String> set = new Set();
dolly.putStringSet("set", set, Type.ENCRYPT);
dolly.putStringSet("set",set, Type.NOT_ENCRYPT);

getStringSet(key, defaultValue, type)

obtener valores de cadena. defaultValue es opcional. en caso de que no se proporcione y falte la clave se devolverá null

dolly.getStringSet("set", null, Type.ENCRYPT);
dolly.getStringSet("set", Type.NOT_ENCRYPT);

putJsonObject(key, value, type)

almacenar valores JSONObject.

JSONObject obj = new JSONObject;
obj.put("name", "Dani");
dolly.putJsonObject("json", obj, Type.ENCRYPT);
dolly.putJsonObject("json",obj, Type.NOT_ENCRYPT);

getJsonObject(key, defaultValue, type)

obtener los valores de JSONObject. defaultValue es opcional. en caso de que no se proporcione y falte la clave se devolverá null

dolly.getJsonObject("json", null, Type.ENCRYPT);
dolly.getJsonObject("json", Type.NOT_ENCRYPT);

remove(key, type)

utilícelo para eliminar un par clave: valor de la memoria. ¡Se eliminará ÚNICAMENTE del almacenamiento especificado! (ENCRYPT / NPT_ENCRYPT)

dolly.remove("name", Type.ENCRYPT);

contains(key)

comprueba si una clave ya está almacenada en la memoria (AMBOS cifrados / no cifrados).

removeAll()

Borre todo el espacio de almacenamiento (AMBOS cifrar / descifrar).

Copyright (C) 2020, Amit kremer

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.

.

Compruebe también

Nuevos gadgets de Android y wearables en el Mobile World Congress + ¡Sintoniza un nuevo episodio de #TheAndroidShow la próxima semana!

Publicado por Anirudh Dewani, Director de Relaciones con Desarrolladores de Android Hoy, en el Mobile …

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *