Live Query Couchbase lite peer to peer

I’m making an Android app using Couchbase. There are two devices connected to the same WiFi synchronizing data. I was using Couchbase Sync Gateway but the project needs to be peer to peer, without Sync Gateway in the middle. When I used Sync Gateway every change in one app was updated immediately. But now it’s not working. The function I’m using:

private void showAnswers() {
manager = DataManager.getSharedInstance(getApplicationContext());
answersQuery = Answer.getAnswersForQuestion(manager.database, mQuestion.get_id());
liveQuery = answersQuery.toLiveQuery();

liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
    @Override
    public void changed(LiveQuery.ChangeEvent event) {
        QueryEnumerator result = event.getRows();

        Map<String, Integer> counts = getAnswerCounts(result);

        adapter = (QuestionOptionsAdapter) mQuestionOptions.getAdapter();

        adapter.setAnswerCounts(counts);

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                adapter.notifyDataSetChanged();
            }
        });
    }
});
liveQuery.start();

}
I don’t know why the Live Query change listener isn’t working. It just works once when I start the Activity. Thank you everybody for your help.

1 Like

Did you refer to this sample app that may help.
Specifically, the sample code to start listener and database listener

Are you sure the replication itself is working? Do documents get added to the database?