0
votes

I have some data in my Cloud Firestore Database. The collection's name is buses, and I have 2 documents (bus_id_1 and bus_id_2). I added a button so that when I click it, I get the data from the database in a TextView.

TextView busesText;

private Button btnViewData;
FirebaseFirestore db = FirebaseFirestore.getInstance();
private DocumentReference mDocRef = db.getInstance().document("buses/bus_id_1");

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FirebaseApp.initializeApp(this);
    setContentView(R.layout.activity_main);
    busesText = (TextView)findViewById(R.id.showData);
   }

public void getData(View view){

    mDocRef.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
        @Override
        public void onSuccess(DocumentSnapshot documentSnapshot) {
            if (documentSnapshot.exists()) {
                Bus bus = documentSnapshot.toObject(Bus.class);
                busesText.setText(bus.getLine());
            }
        }
    });
}

When I click the button this is what I get in the console:

W/RenderThread: type=1400 audit(0.0:733273): avc: denied { read } for name="perf_ioctl" dev="proc" ino=4026533695 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0 V/FA: Inactivity, disconnecting from the service

What can be the reason?

1
This message isn't related to any Firebase SDK. That's being logged by something inside the Android platform. - Doug Stevenson
Does your app crash? - Alex Mamo
@AlexMamo No, it does not crash, it just doesn't show the data when I click the button. - Cassara
can you recheck you document sir or post your data from firestore - Ashish

1 Answers

1
votes

Looks like your database does not allow read operations so you need to change the rules of your Firestore Database. It should look like this:-

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}

Note:- allow write only if you want to update the database from app.