- Significant changes compared to
v2.1.0
. - Encryption is no longer bundled with the library; it's now the developer's responsibility to implement it.
SmartStoreX
is now entirely storage-based (CacheDir/FilesDir/Others), with no reliance onSharedPref
.- Introduced
StoreXSmartConfig
for enhanced configuration withSmartStoreX
. - Added an alternative initializer for
StoreXSmartConfig
.
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.rommansabbir:StoreX:3.1.1'
}
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
SmartStoreXInitializer.init(this)
// other initialization code
}
}
val testConfig = StoreXSmartConfig(
context = WeakReference(this) ?: null, // Pass null if SmartStoreXInitializer.init() is called
fileName = "filename",
storeAbleObject = StoreAbleObject(), // Object to be saved, must extend StoreAbleObject.
cachingStrategy = StoreXCachingStrategy.CacheDir, // Options: CacheDir, FilesDir, Others
overwriteExistingFile = true
)
val isWriteSuccessful = SmartStoreX.getInstance().write(testConfig)
Log.d("Write Object", isWriteSuccessful.toString())
val storedObject: StoreAbleObject? =
SmartStoreX.getInstance().read(testConfig, StoreAbleObject::class.java)
Log.d("Retrieved Object", "Object ID: " + (storedObject?.objectId ?: "null"))
val isDeleted = SmartStoreX.getInstance().delete(testConfig)
Log.d("Is Delete Successful", isDeleted.toString())
SmartStoreX.registerSubscriber(
fileName = 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)
}
}
)
SmartStoreX.removeSubscriber(testConfig.fileName)
SmartStoreX.removeAllSubscribers()
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)
For documentation on older versions, please refer to the previous README.
✔ Website
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.