Live query and databse.addChangeListener not called some time while changes in document in couchdb?

I am using couchdb as server and couchbase lite 1.4.4 in android app.
Live query and database add change listener not called some times while changes in document.

Below is my code;

    val query = database?.createAllDocumentsQuery()
    query?.startKey = "refill-device-SERIAL-AB121-0"
    query?.endKey = "refill-device-SERIAL-AB121-7"

    liveQuery = query?.toLiveQuery()
    liveQuery?.addChangeListener { event: LiveQuery.ChangeEvent? ->
        try {
            val enumeration = query?.run()
            if (enumeration != null) {
                for (row in enumeration) {
                    Log.e("CityExplorer", "Row is " + row.documentId + " and key " + row.key)

                    if (row.documentId.startsWith("refill-device-SERIAL-")) {
                        obj = JSONObject(
                        val canisters = gson.fromJson(obj.toString(),

        } catch (e: CouchbaseLiteException) {


You haven’t shown how liveQuery is created/configured.

Note that LiveQuery notifies you when the query results change, not when anything in a document changes. If the query only returns some properties of a document, then changes to other properties won’t affect the query results so you won’t be notified. For best results, the query should return all the properties you want to watch.

Also, again, 1.4 is about two months from end-of-support.

Hii @jens In my code I want to query for 0 to 7 documents which I described in start key and end key. And I want to get if any smaller change occurs in documents, how can I get notifications because database change listener not work when first time app install. What will be a issue? Can you tell me how to implement database change listener implement with replication?

You’ve said it doesn’t work, but you haven’t shown how you set up the change listener, or exactly what goes wrong…?

I setup database change listener in viewmodel class. Actually I am using MVVM pattern. And I set up pulling data first time using replication code in init method and then outside a method of change listener I write a code for database change listener because everytime replication call when any changes occur in database. But i want to ask you one question can I get changes using replication change listener method?

Please show actual code.