Android realtime database inspection

213 Views Asked by At

I am working on an app and using GreenDao for database. So now to debug and inspect and validate database changes I have to do fetch out the database file after making any changes to database.

To get the database file I am following this way. But truly speaking it is very much pain for me to perform a minor change and to check it I have repeat several number of steps again and again.

I have seen that in iOS I have used Realm Database and I used their Realm Browser and that was very easy to use, as that browser showed me changes in real time from simulator.

Now my question is, in Android Did not we have such tool to get changes in real time in Database browser.

I am using SQLite Browser please help and let me know if you know some tools.

1

There are 1 best solutions below

1
On

Its possible with Room with the paging library. Using a MVVM architecture it can be achieved !

The there will be an observer in the activity which will observe the dynamic data changes of the repository. When any data change occurs the observer is triggered and it updates the UI with the new data .

Go through Room & PagingWithViewModel

The configuration of the data from repository and the conversion of it to livedata is important.

 val myPagingConfig = Config(
    pageSize = 50,
    prefetchDistance = 150,
    enablePlaceholders = true
 )

 // The Int type argument corresponds to a PositionalDataSource object.
 val myDataSource : DataSource.Factory<Int, Pojo> =
    myDao.getData()

 val dataList = myDataSource.toLiveData(
    pagingConfig = myPagingConfig,
    fetchExecutor = myExecutor
 )