Is there a way to show a toast only when something has been changed in the database?

Viewed 49

I am making an Android app in combination with a Symfony api. I use Retrofit and Room Library.

Now when I add data to the database, I navigate to another activity. Now I want to show inside this activity a toast with a message that the insertion was done successfull. How can I make sure that only a toast is shown when data is added successfull and not everytime I open the activity?

1 Answers

Unfortunately you need state. You need to remember what has been shown to the user already and - well - not show it if this is the case.

Having said that - I don't believe there are shortcuts. You will not get this feature for free. There will be a bit of work involved, so let's try to minimize that.

I'd probably make a counter on the device side which last message has been shown to the user. I would set the counter to the id of the last message shown. Then you would only need to always increment the counter on the server side.

This is only one way to tackle the problem. There are many others.

Related