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();
}
}
});
}