Jump to content
Bart Kindt

Android: Lost access to my database files after re-install

Recommended Posts

After upgrading to Delphi 12, I could no longer install my personal App (for myself only) on my phone, du to incompatible signature.

So I had to un-install the App, then re-install it.

Before I did this, I copies the master database stucture from the *public* Documents directory to the SDCard and also to my Windows PC using 'OwnFiles'.

Both the 'OwlFiles' and the Android Files programs had full access to it.

After re-installing my App, I no longer can open the database file. I can see it, it exists. But no matter what I try, I can no longer open the file.

 

Android 13.

 

Also after copying the files straight back from the Windows PC (therefore without any original ownership).

 

Now, I don't care *where* the bloddy files are; I can change the location in my App anywhere. But there seems to be no way my app can access *ANY* PUBLIC directories anymore.

But the 'File managers', they CAN have full access!

 

How can I find ANY place on my Android device where I can read a file which is supplied by nother program, OR copied in place by a file manager (from Windows).

How can I for example IMPORT the original files, and then copy them back in place?

 

Bart

 

Share this post


Link to post
1 hour ago, Bart Kindt said:

After re-installing my App, I no longer can open the database file. I can see it, it exists. But no matter what I try, I can no longer open the file.

How exactly are you attempting to open the file? Are you getting an error? If so, what is it?

1 hour ago, Bart Kindt said:

How can I find ANY place on my Android device where I can read a file which is supplied by nother program

I'm no Android expert, but outside of a public folder, I think Android does not allow two apps to share files with each other unless both apps cooperate with each other, ie the providing app has to grant access to the receiving app. And since the providing app in this case is no longer available, you might be SOL.

1 hour ago, Bart Kindt said:

How can I for example IMPORT the original files, and then copy them back in place?

🤷

Share this post


Link to post
3 hours ago, Bart Kindt said:

After upgrading to Delphi 12, I could no longer install my personal App (for myself only) on my phone, du to incompatible signature.

Did you deploy that application in debug mode? If you did, then the application will be signed with debug key stored in debug.keystore that is located in C:\Users\YOURUSERNAME\AppData\Roaming\Embarcadero\BDS\XX.0 where XX is the Delphi release version. For Athens that is 23.0, for Alexandria it is 22.0....

 

One you install your application on a phone, you always need to sign it with same key, otherwise you need to uninstall the application and install it again, but when doing so, you will lose all local files visible to that application and new application signed with different key. The similar would ahppen if you would switch between debug and release keys.

 

Because release key is the one that matters the most, Delphi allows you to specify the location of the release keystore, but when it comes to the debug keystore, if you want to use the same one you need to manually, copy it from previous version folder into a new version folder where it will be picked up, instead of being automatically generated again.

 

You cannot copy your files to the local application storage from the outside. If you want to do that you would have to implement import feature in your application that would be able to copy files from public folder to application local folder. 

 

There are possibly some ways to handle local application storage through adb connection, but I have never done that.

  • Like 2

Share this post


Link to post
45 minutes ago, Dalija Prasnikar said:

>Did you deploy that application in debug mode?

 

I may have stuffed up the mix between Debug/Release and GooglePlay vs Development after I upgraded to 12.

However, I have un-installed the App, and re-installed it, and now I can no longer access the Database files in the *public* Document directory.

This is an issue started in Android 11, but since Android 13 it has become impossible to access (read/write) any files even in the so called 'public' directory structures.

It is a complete disaster, completely idiotic (the are supposed to be PUBLIC) but in the meantime I have lost access to my own files.

 

 

Share this post


Link to post
45 minutes ago, Bart Kindt said:

This is an issue started in Android 11, but since Android 13 it has become impossible to access (read/write) any files even in the so called 'public' directory structures.

If you cannot access the public folder with application built with Delphi 12, and you could with application built with older Delphi, then it is probably that your application needs additional code/configuration added to the manifest, because now application runs as fully compatible with Android 13 which was introduced in Delphi 12. Older application was running in compatibility mode on Android 13 and that is why those additional requirements were not needed. 

 

I don't know what exactly you need to do as my Android applications don't require such access.

Share this post


Link to post

The problem is this.

"Storage updates in Android 11

Android 11 (API level 30) further enhances the platform, giving better protection to app and user data on external storage. This release introduces several enhancements, such as raw file path access, batch edit operations for media, and an updated UI for the Storage Access Framework.

The release also offers improvements to scoped storage, which makes it easier for developers to fulfill their storage use cases after they migrate to using this storage model.

Scoped storage enforcement

Apps that run on Android 11 but target Android 10 (API level 29) can still request the requestLegacyExternalStorage attribute. This flag allows apps to temporarily opt out of the changes associated with scoped storage, such as granting access to different directories and different types of media files. After you update your app to target Android 11, *the system ignores the requestLegacyExternalStorage flag*.

"

But in in 12 and 13 this got even worse. In 13 you now even must request special permissions to read Image files (seperately). Internet info states I am completely stuffed. The only way could be to use the external SDCard. But, there is no fixed access path to this. It seems to depend on the type of phone.

 

I was hoping that somebody in this forum is an Android expert...

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×