Quantcast
Channel: User Mr.Goomer - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Delete FireBase Value Without Knowing The Key Name

$
0
0

So I am working on the memories Firebase app and there is a stage where the user can upload photos to his memory. Each photo has uniq name "ImgLink0","ImgLink1",etc..

The function I am working on is to delete a specific photo when I am pressing a long click, but I can't reach the image in Firebase.

I tried like below but I got stuck because I can't identify the image key:

mDatabase.child(userUID).child("Memories").child(memoryName).child("Images").addValueEventListener(new ValueEventListener() {    @Override    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {        for (DataSnapshot imageSnapshot : dataSnapshot.getChildren()) {            String imagesKey = imageSnapshot.getKey();            String imagesValue = (String) imageSnapshot.getValue();            Log.e("Test","" + imagesKey +"" + imagesValue);        }    }    @Override    public void onCancelled(@NonNull DatabaseError databaseError) {    }});

And this is the data structure:enter image description here

I tried using query too but with no success because I don't have the image key.

Thank you for any help :)


Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>