0

i need to delete a child, What I am looking for is erasing, in order of time,

Example, i the user select "PostDuration" 3Days , I need the post to be deleted in the selected duration

the uid method:

   public static String getUid() {
    String path = FirebaseDatabase.getInstance().getReference().push().toString();
    return path.substring(path.lastIndexOf("/") + 1)

My childs that containt the data its generated by this method:

     FirebaseUtils.getPostRef().child(FirebaseUtils.getUid).setValue(mPost);

the ref:

    public static DatabaseReference getPostRef() {
    return FirebaseDatabase.getInstance()
            .getReference("posts");
}

photo

my Database structure

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Please ensure that the code you share actually compiles. There is no way that `FirebaseUtils.getUid` now compiles, as its missing parentheses. Aside from that, the approach is similar to here: http://stackoverflow.com/questions/32004582/delete-firebase-data-older-than-2-hours. I'd recommend translating that approach to Android and posting your (compiling) code if you get stuck. – Frank van Puffelen May 01 '17 at 01:43
  • Hi @FrankvanPuffelen how can i Add timeStamp value to a my childrens? i can delete this with the "n" days? – TheQuestionerXxx May 02 '17 at 05:10
  • Here's one way: https://firebase.google.com/docs/database/android/offline-capabilities#server-timestamps – Frank van Puffelen May 02 '17 at 14:04

0 Answers0