Couch DB Android Listview LiveQuery data not refreshing and Not calling OnChange Method

java
query

#1

hi i am also facing this issue , that i have multiple device for ex. 5 device when data change in SG data sync into 5 out of 3 or 4 device. this is random happening with data on Devices. some device got refresh data and some are not,

I debug app i have seen that Live Query onChange() Method not calling up, is this a bug or issue from My Side please help me on this
https://goo.gl/eBzMYP
https://github.com/apache/couchdb/issues/1050

this is link of my question if i am doing anythig wrong.

Thanks in Advance . Heare is chunk of code

private void startLiveQuery(View viewItems) {

if (liveQuery == null) {

    liveQuery = viewItems.createQuery().toLiveQuery();
    liveQuery.addChangeListener(new LiveQuery.ChangeListener() {
        @Override
        public void changed(final LiveQuery.ChangeEvent event) {
                Log.d("DataChang","true");
                Log.d("DataError",event.getError()+"");

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try{
                    empAdapter.clear();
                    for (Iterator<QueryRow> it = event.getRows(); it.hasNext(); ) {
                        empAdapter.add(it.next());
                    }
                    empAdapter.notifyDataSetChanged();
                    empAdapter.notifyAll();
                    }catch (Exception e){
                            e.printStackTrace();
                    }
                    tv_datasize.setText("Record Count : "+event.getRows().getCount()+"");
                }
            });

        }
    });
    liveQuery.start();
}

}

i am Calling this method in initCBLite()

private void initCBLite() throws Exception {

manager = new Manager(new AndroidContext(getApplicationContext()), Manager.DEFAULT_OPTIONS);
DatabaseOptions options = new DatabaseOptions();
options.setCreate(true);
database = manager.openDatabase(DATABASE, options);

viewItems = database.getView(String.format("%s/%s", designDocName, byDateViewName));

viewItems.setMap(new Mapper() {
    @Override
    public void map(Map<String, Object> document, Emitter emitter) {
        Object bydate = document.get(MyDatabase.EMPLOYEENAME);
        if (bydate != null) {
            emitter.emit(bydate, document);

        }
    }
}, "2.0");


initItemListAdapter();

startLiveQuery(viewItems);

startSYNC();

}

And i am Calling initCBLite() method in OnCreate()

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cblite_report);
listView = findViewById(R.id.lv_cbliteReport);
tv_datasize = findViewById(R.id.tv_size);
myDatabase = new MyDatabase(CBLiteReport.this);
db = myDatabase.getWritableDatabase();
try {
initCBLite();

} catch (Exception e) {
    e.printStackTrace();
}

}


#2

@hod.greeley? @hideki?


#3

DB020 is different from db019 or before,“viewItems.createQuery()” does’t only have"Query.select(SelectResult.expression(Expression.meta().getId())" ,it must have the changed property “SelectResult.expression(Expression.property(“xxxx”)))”.