simplekeyvaluestorage

A simple Shared preference wrapper to store POJO objects in Android serialized with gson

License

License

Categories

Categories

KeY Data Data Formats Formal Verification
GroupId

GroupId

com.quinientoscuarenta
ArtifactId

ArtifactId

simplekeyvaluestorage
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

aar
Description

Description

simplekeyvaluestorage
A simple Shared preference wrapper to store POJO objects in Android serialized with gson
Project URL

Project URL

https://github.com/540/simplekeyvaluestorage
Source Code Management

Source Code Management

https://github.com/540/simplekeyvaluestorage

Download simplekeyvaluestorage

How to add to project

<!-- https://jarcasting.com/artifacts/com.quinientoscuarenta/simplekeyvaluestorage/ -->
<dependency>
    <groupId>com.quinientoscuarenta</groupId>
    <artifactId>simplekeyvaluestorage</artifactId>
    <version>1.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.quinientoscuarenta/simplekeyvaluestorage/
implementation 'com.quinientoscuarenta:simplekeyvaluestorage:1.0.1'
// https://jarcasting.com/artifacts/com.quinientoscuarenta/simplekeyvaluestorage/
implementation ("com.quinientoscuarenta:simplekeyvaluestorage:1.0.1")
'com.quinientoscuarenta:simplekeyvaluestorage:aar:1.0.1'
<dependency org="com.quinientoscuarenta" name="simplekeyvaluestorage" rev="1.0.1">
  <artifact name="simplekeyvaluestorage" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.quinientoscuarenta', module='simplekeyvaluestorage', version='1.0.1')
)
libraryDependencies += "com.quinientoscuarenta" % "simplekeyvaluestorage" % "1.0.1"
[com.quinientoscuarenta/simplekeyvaluestorage "1.0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.6.2
com.android.support » appcompat-v7 jar 23.2.1

Project Modules

There are no modules declared in this project.

SimpleKeyValueStorage

Build Status Download Maven Central


A simple Shared preference wrapper to store POJO objects in Android, serialized with gson.

Library Objectives

Tired of having to manually serialize/unserialize objects content into shared preferences this library uses gson to automate object serialization and make painless object storage into shared preferences. Objects are stored json encoded.

Installation

Grab via Gradle:

compile 'com.quinientoscuarenta:simplekeyvaluestorage:1.0.1'

or Maven:

<dependency>
  <groupId>com.quinientoscuarenta</groupId>
  <artifactId>simplekeyvaluestorage</artifactId>
  <version>1.0.1</version>
</dependency>

Usage

Initialize:

You can initialize it with default name 'skvs_default_prefs'

SimpleKeyValueStorage.initDefault(context);

Or with custom name

SimpleKeyValueStorage.builder().withName('custom_name').init(context);

You will have to provide a context, it can be application or activity context.

Use:

Set method accepts any type such as list, object, primitive...

Locale locale = Locale.ENGLISH;
simpleKeyValueStorage.set("key", locale);

Get or get list and specify the content type to retrieve the saved value

Locale savedLocale = simpleKeyValueStorage.get("key", Locale.class);

List<String> savedStrings = simpleKeyValueStorage.getList("key", String[].class);

Delete value

simpleKeyValueStorage.delete("key");

Check data availability

boolean available = simpleKeyValueStorage.isSet("key");

Clear all storage

simpleKeyValueStorage.clear();

Proguard

#Gson
-keep class com.google.gson.** { *; }
-keepattributes Signature

License

Copyright 2015 Gorka Moreno Asín

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

540

Versions

Version
1.0.1
1.0.0