HI. I need to reset the value of a Tag in tinydb

HI

I want to clear the values in a Tag in tinydb when my application closes.
So I call Tinydb.ClearTag when the event occurs. Eg. when.CloseButton.click Call TinyDb.ClearTag. And this works fine.

However, here is my problem/

If the user closes the app, without using the CloseButton in my app.
i.e if the user closes the app from the android phone... then I didnt clear my tag and then my app does not work.

I cannot Clear the Tag at screen.initialize because i am adding another value to the same tag when screen.initialize

is there a when app closed block?? or any other way to ensure that the tag is cleared even if the app is closed "externally"

Please show us your block

Screen4

This is a simplified view of the problem I want to solve. In screen 3, when I close it with back.pressed or closeButton, i am restoring x to 0.

But if user closed the app from the phone, then is there a way to still make x=0 any other idea? If there was a when app.closed block then that would have solved my problem.

when the app opens, i need to check if x=o or 1. and it has tasks in each case.

The first image, upper image is from screen 3.

The second image (the one which is down ) is from the screen 4

I think this can help you :

This block can delete all existing tags in tinydb :
blocks (1)

This block can delete 1 tag that you want :
blocks (2)

This block can delete 1 tag that you want too, but this block checks if the value is there or not, so if the value exists it means it will delete the tag :
blocks

1 Like

Hi, thanks for the help.

I wanted to know if there is a way to clear tags from tinyDb when the application is closed externally ie from the android screen.

sorry I don't think there's any way to it

Yes

Get Taifun's Tools Extension
Use the ActivityStateChanged event block to get State - pause/stop/resume

3 Likes

Wow I got it, thank you @TIMAI2

You want to clear all tags when the app is closed. This implies that when the app is opened, there should be no values tagged in the tinyDb. So Clear all Tags when Screen1 Intialises.

2 Likes

But the app is not "closed", necessarily, when the users leaves the app via the back or home button, it can still be opened where it was "left" using the Overview/Recent button.

I wrote an app a while back that called in/used very sensitive data, I could not trust the users to properly exit the app, therefore as soon as the app was "paused" all the data was cleared/deleted, app more or less restarted, and requiring a new login.

3 Likes

Sir.

ActivitiyStateChanged is exactly the stuff I needed. It works and feels like magic . Woow. Thank you. Thank you. Thank you.
Many bows to you for making it.

1 Like

It wasn't me, it was @Taifun

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.