Skip to content

Latest commit

 

History

History
96 lines (82 loc) · 3.26 KB

README.md

File metadata and controls

96 lines (82 loc) · 3.26 KB

Maven Central License API API Total Clones Total Views

TinyDB

Getting tired by usign the default Shared Preferences class? TinyDB is a lightweight and easy to use Android library that provides user to save data in shared preferences by just a few steps.

  • Min SDK 16 (Android Jellybean 4.1)
  • Written in Java

A lightweight, easy-to-use Android library that lets us to keep data in shared preferences also with objects and much more features

Installation

Add the dependency to your module build.gradle:

dependencies {
    ...
    implementation 'com.saadahmedev.tinydb:tinydb:1.0.0'
}

Usage

Get all features of default Shared Preferences class:

TinyDB.getInstance(this)
        .putString("key1", "Hello")
        .putString("key2", "World")
        .putInt("key3", 5)
        .putLong("key4", 123456789)
        .putBoolean("key5", true)
        .putStringSet("key6", set)
        .apply();
String value = TinyDB.getInstance(this).getString("key1", "Default Value");

Get some extra cool features from TinyDB:

  • Put and Get Object
Student student1 = new Student();
Student student2 = new Student();

student1.setName("Fahad");
student1.setAge(36);

student2.setName("Saad");
student2.setAge(22);

TinyDB.getInstance(this)
      .putObject("key1", student1)
      .putObject("key2", student2)
      .apply();
Student student = TinyDB.getInstance(this).getObject("key1", Student.class);
  • Put and Get Uri
TinyDB.getInstance(this)
        .putImageUri("key1", uri)
        .apply();
Uri uri = TinyDB.getInstance(this).getImageUri("key1");
  • Put and Get Bitmap
TinyDB.getInstance(this)
        .putImageBitmap("key1", bitmap)
        .apply();
Bitmap bitmap = TinyDB.getInstance(this).getImageBitmap("key1");

License

Copyright 2022 Saad Ahmed

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.