# Deleting confidential local data before exiting an app

**URL:** <https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, database, privacy, handler\
**Created:** [March 30, 2019, 3:50pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768 "2019-03-30T15:50:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ritvik\_Singh1](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Ritvik\_Singh1](https://community.thunkable.com/u/Ritvik_Singh1)\
**Post date:** [March 30, 2019, 3:50pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/1 "2019-03-30T15:50:12Z")

</div>

My app requires sensitive and confidential data from users which is then stored locally on the device in a local database. This data is essential and used by my app during a user session but I want it to be deleted before exiting the app to reduce the chance of the data being compromised. While Thunkable offers several ways to store data locally on the device as per the best of my knowledge, all of these methods offer persistent storage. Furthermore, Thunkable does not provide an exit app handler so I am unable to understand how this might be achieved. Can someone help? 🙂

---

<div class="post-metadata">

**Author:** ![Cian\_O\_Sullivan](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cian_o_sullivan/32/34494_2.png) [@Cian\_O\_Sullivan](https://community.thunkable.com/u/Cian_O_Sullivan)\
**Post date:** [March 30, 2019, 6:47pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/2 "2019-03-30T18:47:29Z")

</div>

I do not know how to do it in Thunkable X, but you can do it in classic. You use a random number generator, and create a unqiue key for each session. All data is encrypted locally. When the session ends, the data is encrypted and not recoverable because of the lost random key. You then check if old data is there and delete it on restarts. Good if the phone crashes or battery dies.

There is no native encryption function I could find in X.

---

<div class="post-metadata">

**Author:** ![Ritvik\_Singh1](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Ritvik\_Singh1](https://community.thunkable.com/u/Ritvik_Singh1)\
**Post date:** [March 30, 2019, 8:05pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/3 "2019-03-30T20:05:47Z")

</div>

That is an interesting idea for sure but if you wish to access the same data again you need to store and use the same unique key again right? So can someone not just use the unique key from where it is stored and access the encrypted data?

---

<div class="post-metadata">

**Author:** ![Cian\_O\_Sullivan](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cian_o_sullivan/32/34494_2.png) [@Cian\_O\_Sullivan](https://community.thunkable.com/u/Cian_O_Sullivan)\
**Post date:** [March 30, 2019, 8:08pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/4 "2019-03-30T20:08:30Z")

</div>

If it is in the same session the key is stored as a variable and the user wont see it.

---

<div class="post-metadata">

**Author:** ![Ritvik\_Singh1](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Ritvik\_Singh1](https://community.thunkable.com/u/Ritvik_Singh1)\
**Post date:** [March 30, 2019, 8:21pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/5 "2019-03-30T20:21:39Z")

</div>

I know this might sound dumb but I could really use some help here. So are not all the variables in Thunkable persistent- I mean if the phone crashes or dies down, will not the variables still hold the previous values when the app is launched again? If yes, then can the user, and by extension hackers, not access the value of a variable?

---

<div class="post-metadata">

**Author:** ![Cian\_O\_Sullivan](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cian_o_sullivan/32/34494_2.png) [@Cian\_O\_Sullivan](https://community.thunkable.com/u/Cian_O_Sullivan)\
**Post date:** [March 30, 2019, 8:49pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/6 "2019-03-30T20:49:14Z")

</div>

No they are not persistent, and in Classic, they do not even pass from screen to screen

---

<div class="post-metadata">

**Author:** ![maxb](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxb/32/35200_2.png) [@maxb](https://community.thunkable.com/u/maxb)\
**Post date:** [March 31, 2019, 10:59am UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/7 "2019-03-31T10:59:59Z")

</div>

I think he just found the solution to his problem, am I right? 🙂

---

<div class="post-metadata">

**Author:** ![Ritvik\_Singh1](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Ritvik\_Singh1](https://community.thunkable.com/u/Ritvik_Singh1)\
**Post date:** [March 31, 2019, 11:56am UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/8 "2019-03-31T11:56:14Z")

</div>

It’s a neat solution but I had a few more final questions:

1. Since Thunkable X does not have any native encryption function so even after generating the random key, it would be a challenge to encrypt the user data. What alternative would you recommend for that?
2. In theory, is this method not foolproof as a brute-force attack might still reveal the actual user data when the right key is tested?
3. Not entirely related but is the user data automatically encrypted while it is being transmitted to Firebase for saving or it is something that we need to do ourselves? If yes, then how can I store the encryption key to decrypt the data later?

Thank you @Cian_O_Sullivan for being so proactive in answering my queries!!

---

<div class="post-metadata">

**Author:** ![Cian\_O\_Sullivan](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cian_o_sullivan/32/34494_2.png) [@Cian\_O\_Sullivan](https://community.thunkable.com/u/Cian_O_Sullivan)\
**Post date:** [March 31, 2019, 12:32pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/9 "2019-03-31T12:32:51Z")

</div>

1. There is no embedded solution in Thunkable X right now.
2. Sure you could try to brute force it, but if your randomized the salt and the key, it would take thousands of years to decrypt.
3. If the key is in play, it can be decrypted. There is SSL encryption for firebase, and it meets PCI standards (same standards for credit cards), so the data in transit is encrypted. If you want to decrypt the data later, you would need to find a way to store the key in some encrypted manner. But now you are talking about something different then what you originally asked, which was, store on device, and never use again if application closes.

---

<div class="post-metadata">

**Author:** ![Ritvik\_Singh1](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Ritvik\_Singh1](https://community.thunkable.com/u/Ritvik_Singh1)\
**Post date:** [March 31, 2019, 2:09pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/10 "2019-03-31T14:09:25Z")

</div>

That helps a lot. Thank you!!

---

<div class="post-metadata">

**Author:** ![maxb](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxb/32/35200_2.png) [@maxb](https://community.thunkable.com/u/maxb)\
**Post date:** [April 1, 2019, 11:54am UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/11 "2019-04-01T11:54:05Z")

</div>

> [@maxb](#):
>
> I think he just found the solution to his problem, am I right? 🙂

What i meant in here is that if you need the value to delete when you close the app you might just use a normal variable, not?

---

<div class="post-metadata">

**Author:** ![Ritvik\_Singh1](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Ritvik\_Singh1](https://community.thunkable.com/u/Ritvik_Singh1)\
**Post date:** [April 1, 2019, 5:24pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/12 "2019-04-01T17:24:18Z")

</div>

> [@maxb](#):
>
> What i meant in here is that if you need the value to delete when you close the app you might just use a normal variable, not?

That might be a fair solution in other cases but my app utilizes nearly 150 independent variables when all the screens are considered together so it would be more appropriate to store and retrieve their values from a local database in the best interest of the processing speed and memory usage. But sure a normal variable can be used for other projects!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:15pm UTC](https://community.thunkable.com/t/deleting-confidential-local-data-before-exiting-an-app/73768/13 "2024-11-08T12:15:54Z")

</div>


