Android Question Problem retrieving imported data saved with File.DirRootExternal with API 30

energypf

Member
Licensed User
Longtime User
Hello, I have developed an App that saves patient medical reports in a folder outside the app.
Example: "/storage/emulated/0/appname/report.pdf".
Having ascertained that with the new versions it is no longer possible to use this function, I would like to understand how to release the new version which will be the new reports in an allowed folder, but which at the same time can move the old reports downloaded to the new app folder?
Otherwise, releasing the new version the user will find himself with the empty archive.
I also wanted to know which folder you recommend to use to save the new reports which should remain even if the user uninstalls the app.
Thanks in advance
 

energypf

Member
Licensed User
Longtime User
As I said above in post #6. Have you actually tried using External Storage to access your folder?
Unfortunately google rejected my App. I was wondering if the only alternative for recovering the files in the "/ storage / emulated / 0 / appname" folder is ContentChooser? Furthermore, since many files are present in the folder, there is a method to make a multi-selection or better to use a start directory when using the ContentChooser,
Eg.
CC:
 CC.Show ("application/pdf", "Choose pdf", "/storage/emulated/ 0/appname")

just to limit user intervention to a minimum.

Thanks everyone for the help.
 
Upvote 0

energypf

Member
Licensed User
Longtime User
I agree.

The other option which might be better, is to use XUI.DefaultFolder = File.DirInternal and provide an option for the user to export / import the data. You can create a zip file with all relevant files.
You can then use the "SaveAs" code for export and ContentChooser for import. The user will be able to save it on their Google Drive, external storage and many other places.
Hi Erel, unfortunately Google has discarded the app as I imagined, I was wondering which way to go to allow my users to recover all the files downloaded with my app and stored in the "/storage/emulated/0/appname" folder?

I was thinking of sending an update of my app that no longer uses the direxternal, but that would allow you to download an APK (outside Google Play) that would allow you to move the files of the folder into the one inside the app through DirRootExternal permissions.

Or is there some other method via the ContentChooser with multi-selection?

Thanks in advance, but I don't know how to get out unfortunately.
 
Upvote 0

energypf

Member
Licensed User
Longtime User
Thanks Erel, I am trying to use ExternalStorage and I can access the file list of the selected folder, but I am trying to open the PDF files contained in the folder, but I cannot. I enclose the example I am using. Thank you
 

Attachments

  • ExternalStoragePDF.rar
    349.7 KB · Views: 120
Upvote 0

agraham

Expert
Licensed User
Longtime User
Use File -> Export as Zip to share a non-B4XPages project so you don't include unwanted payload.

You are missing the necessary manifest entry to use FileProvider. It works if you add this
B4X:
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
 
Upvote 0

energypf

Member
Licensed User
Longtime User
Use File -> Export as Zip to share a non-B4XPages project so you don't include unwanted payload.

You are missing the necessary manifest entry to use FileProvider. It works if you add this
B4X:
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
Thanks, it works perfectly.
I would like to know something now, since with ExternalStorage I can access a folder outside that of my app (requesting permission from the user during the selection phase), does this authorization remain forever linked to the app? In the sense that I can copy and read from that folder without asking the user for permission anymore?
 
Upvote 0

energypf

Member
Licensed User
Longtime User
Your demo app already does this if you leave the 'Use previously selected' check box ticked.
Perfect everything works correctly. I have one last question, which folder do you recommend to use (within the app) which is part of the automatic device backup on google? Eg my App downloads pdf files and these files are backed up. Thank you
 
Upvote 0

energypf

Member
Licensed User
Longtime User
What do you mean by this?
I use this function "rp.GetSafeDirDefaultExternal (" Download ")" as the storage path. I wanted to know if this folder is included in the backup that is made of the device via Google Backup. So in case of restore if the app was reinstalled with the downloaded files inside? Thank you
 
Upvote 0
Top