I'm actually trying to fetch all document id's from firestore database into array adapter for that i'm using document.getid() but instead of fetching all document id's together it instead fetches them one by one however what i actually want that all id's should be displayed in a list how can i counter this problem any help will be appreciated. Take a look at the code i'm trying to implement.
public void onClick(View v) {
if (position==0) {
db.collection("Listening")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
if (document != null) {
AlertDialog.Builder builderSingle = new AlertDialog.Builder(mContext);
builderSingle.setTitle("Select A Test");
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext, android.R.layout.select_dialog_singlechoice);
// for (int i=0;i<document.getId().;i++) {
// }
builderSingle.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String strName = arrayAdapter.getItem(which);
Intent intent=new Intent(mContext,Listening.class);
intent.putExtra("tname",strName);
mContext.startActivity(intent);
}
});
builderSingle.show();
} else {
Log.d("LOGGER", "No such document");
}
}
} else {
Log.w(TAG, "Error getting documents.", task.getException());
}
}
});
}
}
});