Skip to content

How to display integer from firebase firestore to Android Studio’s TextView?

I’m currently making a project in which a user segregates their trash and in return, it gives them points. Using those points they can redeem awards. At the moment I’m having trouble how to display the points in Android Studio’s TextView. This is my code. my database structure I want the points to be displayed on my TextView which is on my dashboard the problem occurs at the DocumentReference portion.

public class MainActivity extends AppCompatActivity {
private TextView powents;
FirebaseFirestore fStore;

protected void onCreate(Bundle savedInstanceState) {

    Button logout = findViewById(;
    ImageView qrimage = findViewById(;
    powents = findViewById(;
    fStore = FirebaseFirestore.getInstance();

    DocumentReference docref = fStore.collection("Users").document("Users");
    docref.addSnapshotListener(this, (documentSnapshot, error) -> {


    try {
        BarcodeEncoder barcode = new BarcodeEncoder();
        Bitmap bitmap = barcode.encodeBitmap(Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getEmail(), BarcodeFormat.QR_CODE, 650, 650);
    } catch (Exception e) {

    logout.setOnClickListener(view -> {
            Toast.makeText(MainActivity.this, "Logged Out!", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(MainActivity.this, Login.class));




The problem in your code seems to be at this line of code:

DocumentReference docref = fStore.collection("Users").document("Users");

When you’re using the above reference, it means that you are trying to read a document that has an ID called Users, which actually doesn’t exist, since your screenshot shows that the document ID is [email protected]. To solve this, simple change to above document reference to:

DocumentReference docref = fStore.collection("Users").document("[email protected]");

And your code should, as long as you have proper rules. Don’t also forget to attach a failure listener as well, to see if something goes wrong.