Files
coco 723ce1af5c a
2026-07-03 15:12:48 +08:00

875 B

Database handlers

Usage

  1. Add JitPack to your project build.gradle
allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
   }
}
  1. Add the dependency in the application build.gradle
dependencies {

implementation "com.github.FunkyMuse.KAHelpers:database:$utilsVersion"

}
  1. Simple usage
//inside your ViewModel
 private val favoritesData: MutableLiveData<DBResult<List<MyModel>>> = MutableLiveData()
 val favorites: LiveData<DBResult<List<MyModel>>> = favoritesData
 
 private fun getAll() {
        makeDBCallFlow(favoritesData) {
            favoritesRepo.getAll()
        }
    }
//your getAll method 
@Query("select * from myFavorites") fun getAllFavorites(): Flow<List<MyModel>>