Android Live query on a document not working

I am trying to get real time changes on a document using the changelistener, however i have to refresh tha mobile app to see the change. Here is my gist

Please help me out if you have a solution

Hi @mikekara,

The document change listener should trigger when saving new revisions.

Can you share the code you have to register the change listener and update the document?


Hi @jamiltz, thank you for replying, I am using this code to read a value from the document in real time, I think my problem is how to use it to update the textview from within the changeListener

retrieve = database.getDocument(accou);
            Map<String, Object> properties = retrieve.getProperties();
            owner = (int) properties.get("account");
            Log.d(TAG, "doc "+owner);
            retrieve.addChangeListener(new Document.ChangeListener() {
                public void changed(Document.ChangeEvent event) {
                    DocumentChange docChange = event.getChange();
                    String msg = "New revision added: %s. Conflict: %s";
                    msg = String.format(msg,
                            docChange.getAddedRevision(), docChange.isConflict());
                    Log.d(TAG, msg);
            try {
            } catch (CouchbaseLiteException e) {

Can you see the logs in the console?

For UI code in the change listeners, use the runUiThread block:

runOnUiThread(new Runnable() {
    public void run() {
        // update text view's text

Yes it worked!! Thank you so much @jamiltz, you are a life saviour!