I'm using Firebase Cloud Firestore with Firestore UI RecyclerView to display items on MainActivity
. Everything works fine except that, when I uninstall and re-install the app, query
does not fetch previously added items and only an empty list appears. When I add a new item to Firestore after re-install, only that item is fetched and still no previous data. However, I can see both previously added data and the new item on Firebase Console.
Has anyone experienced a similar issue or any idea what can cause this?
My function that sets up the RecyclerView
is as follows. I call this function and then call adapter.startListening()
in onStart
and adapter.stopListening()
in onStop
.
private void setupRecyclerView() {
if(shouldStartSignIn()) return;
if(!PermissionUtils.requestPermission(this, RC_STORAGE_PERMISSION, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Log.e(TAG, "Permission not granted, don't continue");
return;
}
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
pagesRecyclerView.setLayoutManager(layoutManager);
Query query = FirebaseFirestore.getInstance().collection(Page.COLLECTION).whereEqualTo(Page.FIELD_USER_ID, FirebaseAuth.getInstance().getCurrentUser().getUid()).orderBy(Page.FIELD_TIMESTAMP).limit(50);
FirestoreRecyclerOptions<Page> options = new FirestoreRecyclerOptions.Builder<Page>().setQuery(query, Page.class).build();
adapter = new PagesAdapter(options, this);
pagesRecyclerView.setAdapter(adapter);
}