0

we have two apps. The first one is creating some audio files and save in internal storage (Shared storage according to android 11). The first app is creating an audio file and shared the audio file path to our second app and the second app access that audio file using the file path and upload it to the server.

We are using contentProvider to share the filePath to the second app.

Our first app is able to create audio files in internal(shared) storage because its target SDK version is still 26.

But we have changed the target SDK version of our second app to 30 (android 11), Because of the android 11 restriction, our second app is not able to access those audio files from internal (Shared storage) using the file path provided by the first app. Permission denied exception is coming if I am trying to access those files.

And those audio files are saved in the 'my_recrodings' folder. which is created by the first app in shared storage.

Full Path = /storage/emulated/0/.my_recrodings/

Please help me. How can I access those files?

Chandan
  • 187
  • 1
  • 8
  • Have you added permissions in Android Manifest? – JustinW Oct 28 '21 at 11:19
  • we have added READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE premission – Chandan Oct 28 '21 at 11:29
  • You need MANAGE_EXTERNAL_STORAGE permission – Dan Baruch Oct 28 '21 at 11:34
  • Apart from asking MANAGE_EXTERNAL_STORAGE permission, is there any other way of accessing those files? – Chandan Oct 28 '21 at 11:38
  • Maybe, [this](https://stackoverflow.com/questions/64720379/writing-many-files-on-android-11) would help – JustinW Oct 28 '21 at 11:40
  • `(Shared storage according to android 11). ` Please be more specific. – blackapps Oct 28 '21 at 11:41
  • 1
    App 1 can use FileProvider to serve file to app2. – blackapps Oct 28 '21 at 11:42
  • `those audio files are saved in the 'my_recrodings' folder` That folder you could have created anywhere . Full path please. – blackapps Oct 28 '21 at 11:43
  • `using the file path provided by the first app. ` Please be more specific about how app1 provides that path yo app2. – blackapps Oct 28 '21 at 11:45
  • @blackapps Shared storage means internal storage (/storage/emulated/0). For the rest of the confusion, I have updated the question. – Chandan Oct 28 '21 at 11:54
  • The path /storage/emulated/0 is not shared across apps in general. I think the link given by @JustInCoding would help you best if you are not looking to use MANAGE_EXTERNAL_STORAGE – Dan Baruch Oct 28 '21 at 12:04
  • Your app on an Android 11+ device cannot create that hidden directory in root of external storage. /storage/emulated/0/.my_recrodings. Please tell how your app did that. – blackapps Oct 28 '21 at 12:19
  • 1
    `We are using contentProvider to share the filePath to the second app.` Your own content provider? Or FileProvider? If you use your own you can serve the file itself too. Very good solution. And... You do not even have to save your file to external syorage but can keep it private in getFilesDir() and such. Also with FileProvider you do not need external storage or any permission. – blackapps Oct 28 '21 at 12:26
  • 1
    "We are using contentProvider to share the filePath to the second app" -- share the content, not the path. As suggested, `FileProvider` would do this for you, or you could add support for it to your own provider. – CommonsWare Oct 28 '21 at 12:27

1 Answers1

0

It's not storage, but you can use a service with AIDL to communicate between apps:

The Android Interface Definition Language (AIDL) is similar to other IDLs: it lets you define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).

https://developer.android.com/guide/components/aidl

You may also need to define a query for Android 11 (API level 30)

<manifest package="com.example.game">
  <queries>
    <!-- Specific apps you interact with, eg: -->
    <package android:name="com.example.service" />
  </queries>
  ...
</manifest>
user3394003
  • 119
  • 1
  • 2