xCa0z
xCa0z

Reputation: 11

Android how to configure provider path for dual app storage

Two connected questions:

  1. Environment.getExternalStorageDirectory().getAbsolutePath() gives me the external storage. But I just noticed that dual apps (You can clone apps for example on Xiaomi) have their own external storage path. Whats the way to get that programmatically? I looked it up and on my phone it's "/storage/emulated/0" for normal apps and "/storage/emulated/999" for cloned apps. I suppose that other device manufacturers use different paths and I can not hardcode this, correct?

  2. (by using the hardcoded location of dual apps) I've read the files that were saved by the cloned app from the location "/storage/emulated/999/Pictures/9GAG/", there are all 14 showed in my app, but when I try to share them or copy to clipboard, the fileprovider doesnt seem to be able to access these files:

jnius.jnius.JavaException: JVM exception occurred: Failed to find configured root that contains /storage/emulated/999/Pictures/9GAG/Or-if-you-eat-the-Mona-Lisa.jpg java.lang.IllegalArgumentException

The path definitely exists, I see the images in my app folder.

Right now my provider_paths.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<paths>
      <external-path
        name="external"
        path="." />
      <external-files-path
        name="external_files"
        path="." />
      <cache-path
        name="cache"
        path="." />
      <external-cache-path
        name="external_cache"
        path="." />
    <files-path
        name="files"
        path="." />
</paths>

What do I need to add? Or is the problem something different?

Upvotes: 1

Views: 38

Answers (0)

Related Questions