1

I'm publish a post on firebase. I'd like to delete the post in five days automatically.

"-N3PM_bR2DKG6BFYNMlI": {
    "category": "Art and culture",
    "description": "hello again and sorry I was just a little confused as I have been locked out ",
    "name": "heloo",
    "phone": "079655555",
    "posthide": "0",
    "postid": "-N3PM_bR2DKG6BFYNMlI",
    
    "price": "50",
    "publisher": "HMGlcntYlRQdUSyJ2zHaJwpgmwO2",
    "time_end": 1654091199223,
    "time_post": 1654004800172,
    "timestart": 1654004800172
  },

How at the end of 5 days, it automatically deletes itself from the database.

in my apater_post

if (post.getTime_end().equals(post.getTime_post())){


        FirebaseDatabase.getInstance().getReference("Shop")
                .child(post.getPostid()).removeValue()
                .addOnCompleteListener(new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        if (task.isSuccessful()) {
                            Toast.makeText(mContext, "remove", Toast.LENGTH_SHORT).show();
                        }
                    }
                });

    }
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
samer
  • 13
  • 3
  • Have you tried to implement one of the solutions that exist [here](https://stackoverflow.com/questions/54767485/where-should-i-put-a-code-which-take-a-long-time-to-calculate/54767571#54767571)? – Alex Mamo May 31 '22 at 14:29
  • No, I want a countdown to the top of the post when the time expires, deleting the post from the database. – samer May 31 '22 at 14:31
  • In that case, what have you tried to achieve in code? – Alex Mamo May 31 '22 at 14:38
  • Locale LocaleBylanguageTag2 = Locale.forLanguageTag("en"); TimeAgoMessages messages2 = new TimeAgoMessages.Builder().withLocale(LocaleBylanguageTag2).build(); String text2 = TimeAgo.using(Long.parseLong(String.valueOf(post.getTime_post())), messages2); String text3= TimeAgo.using(Long.parseLong(String.valueOf(post.getTime_end())), messages2); – samer May 31 '22 at 14:47
  • And where's the timer? Add the code related to the timer to your question. – Alex Mamo May 31 '22 at 15:49

0 Answers0