Android Question Saving database after uninstalling application

latietude

Member
Hello everyone, I think many of you have been unable to recover the database data entered before uninstalling the application.

Does anyone know how to do it for fun? I tried to enter some codes found on other forums but I could not find the solution.

I enclose a small test project, thank you in advance.
 

Attachments

  • CounterTest.zip
    10.1 KB · Views: 21

latietude

Member
Hello everyone, I think many of you have been unable to recover the database data entered before uninstalling the application.

Does anyone know how to do it for fun? I tried to enter some codes found on other forums but I could not find the solution.

I enclose a small test project, thank you in advance.
<Does anyone know how to do it for fun?>
I apologize because the translator changed "please" to "fun"
Thank you
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
You missed out one important line of code. I have added it.
 

Attachments

  • CounterTest2.zip
    10.1 KB · Views: 27
Upvote 0

latietude

Member
Thank you for the correction but my problem is to be able to resume database data after reinstalling the application.
I’ll explain better, the example application works well if I keep it installed on my phone: every time I restart it the counter resumes from the total number of clicks that I made the previous time. The problem occurs when I uninstall the application because when I reinstall it again the counter, instead of resuming from the total number of clicks made, resets.

I would not lose the data and that when I reinstall it made me resume from where I had arrived before the uninstallation..... if possible.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Sorry - I misunderstood your original question, and then our posts crossed each other. In my opinion the only sensible way to preserve data between installations is to use cloud storage, and that usually also requires some form of user registration. If you want to save data on the device then you need user assistance before they decide to uninstall, and they need to be knowlegeable about where it is stored and how to retrieve it after they have reinstalled the app. This post explains the procedure, but it is not in my opinion very satisfactory for the use you have in mind.
 
Upvote 0

latietude

Member
Sorry - I misunderstood your original question, and then our posts crossed each other. In my opinion the only sensible way to preserve data between installations is to use cloud storage, and that usually also requires some form of user registration. If you want to save data on the device then you need user assistance before they decide to uninstall, and they need to be knowlegeable about where it is stored and how to retrieve it after they have reinstalled the app. This post explains the procedure, but it is not in my opinion very satisfactory for the use you have in mind.
Thank you very much, it’s not exactly the solution I expected to find but at least now I can work on something concrete 🥳
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Check this. This is the only thing that you can use i guess.
I mean beside the use of a cloudstorage for your userdata as pointed out by @Brian Dean . This requires you to have an online-service running to handle this.


Inform about jRDC2, a B4J Serverapp which you could use to have an Online Onlinedatabases like MySQL instead of a Sqlite-Database on the Device.
The app should have access to internet to use jRDC2 for sure.

jRDC2: https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/
 
Last edited:
Upvote 0

latietude

Member
Controlla qui. Questa è l'unica cosa che puoi usare, credo.
Voglio dire, oltre all'uso di un cloud storage per i tuoi dati utente come sottolineato da @Brian Dean . Questo richiede che tu abbia un servizio online in esecuzione per gestirlo.


Informazioni su jRDC2, un'applicazione server B4J che puoi utilizzare per avere un database online come MySQL invece di un database SQLite sul dispositivo.
Per poter utilizzare jRDC2, l'app deve sicuramente avere accesso a Internet.

jRDC2: https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/
Thank you
 
Upvote 0

vmag

Active Member
There are no problems at all.
1. Figure out what is considered data for you (this is a database file, possibly several files).
2.Make it possible to copy this data to the phone folder that is available to you and make it possible to copy it back to the application directory.
3.Check the functionality of saving and restoring data by making changes. Now you can save the data, delete the application, install the application and restore the data, everything will remain as it was before the application was deleted.
You are most likely using SQLite storage without disabling the storage copy option., therefore, it is not the working database that is being copied, but it is unclear what...
 
Upvote 0

latietude

Member
Non ci sono problemi di alcun tipo.
1. Scopri cosa per te è considerato un dato (un file di database, forse più file).
2. Rendi possibile copiare questi dati nella cartella del telefono a tua disposizione e rendi possibile copiarli nuovamente nella directory dell'applicazione.
3.Controlla la funzionalità di salvataggio e ripristino dei dati apportando modifiche. Ora puoi salvare i dati, eliminare l'applicazione, installare l'applicazione e ripristinare i dati, tutto rimarrà come era prima che l'applicazione venisse eliminata.
Molto probabilmente stai utilizzando l'archiviazione SQLite senza disabilitare l'opzione di copia dell'archiviazione, quindi non è il database di lavoro che viene copiato, ma non è chiaro cosa...
Salve! Grazie per l'interesse dimostrato per il mio problema, ma forse a causa del traduttore non ho capito il tuo consiglio. Potresti spiegarmelo?
 
Upvote 0

latietude

Member
B4X:
Main.SQL1.ExecQuerySingleResult("PRAGMA journal_mode = delete")

Thank you but unfortunately it does not work either, every time I reinstall the application the counter returns to zero. is like overwriting the database every time I reinstall the app...
 
Upvote 0

latietude

Member
Thank you but unfortunately it does not work either, every time I reinstall the application the counter returns to zero. is like overwriting the database every time I reinstall the app...
I’ve been trying since this morning and can’t get your code line to work so I ask you: have you tried to see if it works in the example project that I attached in post #3? Thank you for your interest in my problem which is driving me crazy.
 
Upvote 0

vmag

Active Member
Thank you but unfortunately it does not work either, every time I reinstall the application the counter returns to zero. is like overwriting the database every time I reinstall the app...
1. You need to save all the necessary data to the external available memory.
2. Check the contents of what you have saved (data, counters, etc.) on the computer.
3. Reinstall the application.
4. Restore the data.
Why doesn't it work:
1. You did not check item 2.
2. Before copying and restoring, delete the old destination files.
3. You don't handle errors.
 
Upvote 0

latietude

Member
1. You need to save all the necessary data to the external available memory.
2. Check the contents of what you have saved (data, counters, etc.) on the computer.
3. Reinstall the application.
4. Restore the data.
Why doesn't it work:
1. You did not check item 2.
2. Before copying and restoring, delete the old destination files.
3. You don't handle errors.
I tried your advice but I can’t get what I want. Every time I uninstall the app my counter is reset, I found that Google no longer allows to read the content of files inserted in DirRootExternal and it’s a great pity since, connecting the phone to the pc, I could see the increase of the counter from the app.

I’m not a professional programmer and I definitely miss something, do you have any other tips that can help me please?

Thank you again for your attention.
 
Upvote 0
Top