Firebase doesn't Recognise the String Key for setting a value

giuseppe :

I have got a ListView Activity loaded with FirebaseDatabse items (users). Once you click an item of the ListView, it passes the item-Key of the related user (FirebaseDatabase Hash)to another Activity, in which there is a confirmation button. Once clicked the confirmation button, it should Set a confirmation value ("Accepted") in the item-field of FirebaseDatabase specified by the user-item-key.

The problem is that it doesn't. I mean, if I use the CURRENT userId hash it sets "Accepted" perfectly in the in the userId field of the FirebaseDatabase, but if I use the Key of another item-user, it doesn't do it. Could anyone tell me why, please?

This is part of the confirmation Activity where the confirmation button is clicked:

 riderKey = intentGet.getStringExtra("riderKey");

        Log.i("KeySetRider", riderKey);
        Log.i("KeySetUser", MainActivity.userId);

        FirebaseDatabase.getInstance().getReference().child("users").child(String.valueOf(riderKey )).child("Request").setValue("Accepted");
       FirebaseDatabase.getInstance().getReference().child("users").child(String.valueOf(MainActivity.userId )).child("Request").setValue("Accepted");

This are the keys I get in the confirmation activities:

2020-02-02 22:15:58.268 10620-10620/com.example.uberapp I/KeySetRider: XhNENH3g68SsrtPhmdFmY 
2020-02-02 22:15:58.268 10620-10620/com.example.uberapp I/KeySetUser: klaunWpq4ASLfiduCoU2d 

![enter image description here]1

![enter image description here]2

Bruno :

Sorry, I can't comment the question so I have to write my comments here, despite I am not really posting a solution.

I notice that the keys you copied from the logcat output are not exactly the same as those appearing in the screenshots. They seem to be truncated. Any idea why? If in the code you try to use the proper constants, instead of the variables, does it work? It could be a problem on how you receive/process those IDs.

An alternative hypothesis could be that the user rights are not set properly in the database, and therefore the user is only allowed to edit their record. Not sure if this is possible with your application, as you only publish those two records and we don't know where they're stored and which DB configuration you have.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=421258&siteId=1