Best android open-source packages and libraries.

StoreX

✔️ Simplify Caching in Android
Updated 4 months ago

StoreX

-----------------------------------------------------

Maintained

Maintained

JitPack

⚡ Latest Version: 3.0.0 | Change Logs 🔰

  • Breaking changes compared to v2.1.0.
  • Encryption is not coming with the library itself anymore. It's developer specific now.
  • SmartStoreX is now completely storage (CacheDir/FilesDir/Others) based, no more SharedPref usages.
  • New configuration StoreXSmartConfig to work with SmartStoreX.

-----------------------------------------------------

Installation

➤ Step 1:

Add the JitPack repository to your build file .

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

➤ Step 2:

Add the dependency.

    dependencies {
            implementation 'com.github.rommansabbir:StoreX:3.0.0'
    }

➤ Step 3:

How to Access SmartStoreX.

  • First, create an instance of StoreXSmartConfig :
    val testConfig = StoreXSmartConfig(
        WeakReference(this),
        "filename",
        StoreAbleObject(), //Object to be saved, must be a instance of StoreAbleObject.
        StoreXCachingStrategy.CacheDir, // Caching directory: CacheDir-FilesDir-Others
        overwriteExistingFile = true
    )
  • To write an object :
   val isWriteDone = SmartStoreX.getInstance.write(testConfig)
   Log.d("Write Object", isWriteDone.toString())
  • To get a written object :
    val storedObject: StoreAbleObject? =
        SmartStoreX.getInstance.read(testConfig, StoreAbleObject::class.java)
    Log.d("Written Object", "Object ID: " + (storedObject?.objectId ?: "null"))
  • To delete a written object :
    val isDeleted = SmartStoreX.getInstance.delete(testConfig)
    Log.d("Is Delete Done", isDeleted.toString())

How to manage Subscription (Write/Delete).

  • To register a subscriber :
    SmartStoreX.registerSubscriber(
        testConfig.fileName,
        subscriber = object : StoreXSubscription {
            override fun <T : StoreAbleObject> onCallback(fileName: String, updatedObject: T) {
                Log.d("Write Callback", updatedObject.objectId)
            }

            override fun <T : StoreAbleObject> onDelete(fileName: String, deletedObject: T) {
                Log.d("Delete Callback", deletedObject.objectId)
            }
        })
  • To remove a subscriber :
    SmartStoreX.removeSubscriber(testConfig.fileName)
  • To remove all subscribers :
    SmartStoreX.removeAllSubscriber()
  • Objects that are extended from StoreAbleObject :
StoreAbleString("Value")
StoreAbleInt(1)
StoreAbleDouble(1.0)
StoreAbleLong(1234567890879)
StoreAbleByte(Byte)
StoreAbleChar(Char)
StoreAbleShort(Short
StoreAbleArrayList(Arraylist)
StoreAbleMutableList(MutableList)
StoreAbleSet(Set)
StoreAbleMutableSet(MutableSet)
StoreAbleHashMap(HashMap)
StoreAbleHashSet(HashSet)

Looking for old version documentation? Click here to see.

-----------------------------------------------------

Contact me

LinkedIn

Website

-----------------------------------------------------

License

Apache Version 2.0

Copyright (C) 2023 Romman Sabbir

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.
Tags cache