Android Question use File Provider to share files

ilan

Expert
Licensed User
Longtime User
hi

i noticed that if i want to use file provider to share a file i can do that only from the shared folder (rp.GetSafeDirDefaultExternal("shared") )

i guess its because i create in manifest only the resource for that path:


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,
   <external-files-path name="name" path="shared" />
)

is it possible to use file provider to share a file directly from File.DirRootExternal ??

thanx, ilan
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

ilan

Expert
Licensed User
Longtime User
hi again

i am trying to add that path but the compiler does not like it

B4X:
CreateResource(xml, provider_paths,
   <external-files-path name="name" path="shared" />
   <external-path name="name" path="" />
)

error:
B4A Version: 8.00
Parsing code. (0.24s)
Compiling code. (0.22s)
Compiling layouts code. (0.11s)
Organizing libraries. (0.00s)
Generating R file. Error
res\xml\provider_paths:3: error: Error parsing XML: junk after document element

is it limited to only 1 path? according to the FileProvider info page, it is not limited
https://developer.android.com/reference/android/support/v4/content/FileProvider.html

example for more than 1 path:

<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="my_images" path="images/"/>
<files-path name="my_docs" path="docs/"/>
</paths>

how to do that in b4a?

thanx, ilan
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
At least you can create the complete file manually and put it in a Resourcefolder.

Put the folder res.Fileprovider in your PROJECT DIR... (where the b4a file is)
Reference it with
B4X:
#AdditionalRes: res.FileProvider

Dont forget to remove the createresource from the manifest editor.
 

Attachments

  • res.Fileprovider.zip
    512 bytes · Views: 245
Upvote 0
Top