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

Brian Dean

Well-Known Member
Licensed User
Longtime User
You do not say if you plan to publish your app in the Playstore. If you do not need to meet Playstore rules then you have two possible options -

1. You can set your app's android:targetSdkVersion in the Manifest Editor to an older level, before the current restrictions were introduced. I think that level 29 works.

2. You can use the path described in this post - this is an old post now but I expect that it still applies

You cannot use DirRootExternal to meet your aim if you are writing for recent Android versions. @vmag says this in his first post -
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.
This is what I wrote in post #8 -
If you want to save data on the device then you need user assistance before they decide to uninstall
They are effectively the same thing.
 
Upvote 0

latietude

Member
You do not say if you plan to publish your app in the Playstore. If you do not need to meet Playstore rules then you have two possible options -

1. You can set your app's android:targetSdkVersion in the Manifest Editor to an older level, before the current restrictions were introduced. I think that level 29 works.

2. You can use the path described in this post - this is an old post now but I expect that it still applies

You cannot use DirRootExternal to meet your aim if you are writing for recent Android versions. @vmag says this in his first post -

This is what I wrote in post #8 -

They are effectively the same thing.
This is my problem, I would like the user not to have the possibility to access the database to manipulate the data contained in it.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I would like the user not to have the possibility to access the database to manipulate the data contained in it.
You are suggesting that the app could store data somewhere that no other app could access, but would be somehow retrievable if the original app happened to be installed again. That type of storage has never been available on Android or on any other system (such as Windows) as far as I am aware - and I can see many technical reasons why not.

Achieving the function that you want would need a different approach. The data saved on the system would be obfuscated/encoded/encrypted so that, although it might be accessible, it could not be successfully changed by the user. Of course they might delete it, accidentally or otherwise. That is why storage outside of the system (eg cloud storage) is a better solution.
 
Upvote 0

latietude

Member
You are suggesting that the app could store data somewhere that no other app could access, but would be somehow retrievable if the original app happened to be installed again. That type of storage has never been available on Android or on any other system (such as Windows) as far as I am aware - and I can see many technical reasons why not.

Achieving the function that you want would need a different approach. The data saved on the system would be obfuscated/encoded/encrypted so that, although it might be accessible, it could not be successfully changed by the user. Of course they might delete it, accidentally or otherwise. That is why storage outside of the system (eg cloud storage) is a better solution.
Is exactly what I thought but it’s strange that, if I uninstall the application, and then reinstall it the phone memory cannot keep the database file with the last data entered and re-insert the copy from DirAssets. My idea was to avoid using the cloud.
 
Upvote 0

latietude

Member
You are suggesting that the app could store data somewhere that no other app could access, but would be somehow retrievable if the original app happened to be installed again. That type of storage has never been available on Android or on any other system (such as Windows) as far as I am aware - and I can see many technical reasons why not.

Achieving the function that you want would need a different approach. The data saved on the system would be obfuscated/encoded/encrypted so that, although it might be accessible, it could not be successfully changed by the user. Of course they might delete it, accidentally or otherwise. That is why storage outside of the system (eg cloud storage) is a better solution.
Do you know what this is? (java.io.FileNotFoundException: /storage/emulated/0/Documents/CounterTest4.db: open failed: EACCES (Permission denied))
I tried to put the database from DirAssets in a folder rp.GetSafeDefaultExternal("") and from here in File.DirRootExternal & "/Documents" and I see the database by connecting the phone to the computer, but when reinstalling the app I ask him to take the database and put it back in rp.GetSafeDirDefaultExternal("") freezes and gives me the above error.

For safety I put the permissions in the Manifest Editor but nothing changes...
 
Upvote 0

Jones Hone

Active Member
Licensed User
Longtime User
You can try it like this:
android:targetSdkVersion must="28" 'Must be less than or equal to 28
After installation, manually grant the app permission to access all files.

ps.
I have an app that does just that!
Although I have put WRITE_EXTERNAL_STORAGE in Manifest
But it will not automatically grant permissions, so you need to manually go to the settings screen to grant permissions
 
Upvote 0

latietude

Member
Puoi provare così:
android:targetSdkVersion must="28" 'Deve essere minore o uguale a 28
Dopo l'installazione, concedi manualmente all'app l'autorizzazione ad accedere a tutti i file.

P.S.
Ho un'app che fa proprio questo!
Sebbene abbia inserito WRITE_EXTERNAL_STORAGE nel Manifest
Ma non concederà automaticamente le autorizzazioni, quindi è necessario andare manualmente alla schermata delle impostazioni per concedere le autorizzazioni
Grazie, ci proverò
 
Upvote 0

latietude

Member
You can try it like this:
android:targetSdkVersion must="28" 'Must be less than or equal to 28
After installation, manually grant the app permission to access all files.

ps.
I have an app that does just that!
Although I have put WRITE_EXTERNAL_STORAGE in Manifest
But it will not automatically grant permissions, so you need to manually go to the settings screen to grant permissions
It works! Thank you very much
 
Upvote 0
Top