When I start up my android application, I try to get all of the existing documents from my database. I know for fact that they all exist, since later on in the application I see so using the same exact query. However, on start up, when I try executing the following code, I get no documents from my ResultSet:
private void findDocuments(){
Query query = QueryBuilder
.select(SelectResult.expression(Meta.id),
SelectResult.property("english word"),
SelectResult.property("swedish word"))
.from(DataSource.database(MainActivity.database));
try {
ResultSet resultSet = query.execute();
System.out.println(resultSet.allResults().isEmpty() + "---------" + resultSet.allResults().size()); // this prints statement says prints TRUE and 0
if(MainActivity.database.getCount() == 0){ //the count is NOT 0 here
Log.d("DEBUG", "DB is empty");
} else {
List<Result> documents = resultSet.allResults();
Log.d("DEBUG", "DB is NOT empty" + documents.size());// size is 0 here...
for(Result result: resultSet){//never enters this!
Log.d("DEBUG", result.getString(0));
}
}
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
}
The only thing that I am doing different in my later Activity is that I just create and save a new mutable document and then call the same query as above, which then actually displays all of the documents.
What am I doing wrong?