Skip to main content
Participant
October 30, 2017
Question

AIR for Android fails to load files from File.desktopDirectory on Android 7

  • October 30, 2017
  • 1 reply
  • 852 views

Hello,

I have an AIR app for Android that loads mp4 and mp3 files from a specific directory on the internal storage of an Android device.

Everything works as long as the app is running on Android 6 or lower.

Today I installed the app on a Samsung Galaxy Tab A running Android 7 and it is no longer able to load files from a directory outside the File.applicationDirectory or File.applicationStorageDirectory.
On checking the property File.exists, this is true and also the filepath looks normal.

Loading files from File.applicationDirectory works.

This is very annoying since I have a great deal of rather large video's to load in this app and I don't want to include them in every new APK.

Does anyone have experienced similar behaviour?
Any solutions?

This topic has been closed for replies.

1 reply

Frédéric C.
Inspiring
October 30, 2017

From the top of my head, did you put the READ_EXTERNAL_STORAGE permission in the Android manifest?

https://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE

gri-griAuthor
Participant
October 31, 2017

Yes, all permissions are set correctly and the same as for previous Android versions.

gri-griAuthor
Participant
October 31, 2017

Strange thing is that when I trace File.desktopDirectory.url I get "file:///storage/emulated/0", and when I trace File.desktopDirectory.getDirectoryListing() it returns an empty array.


When I manually change the permissions of the app after installation on the Android device, everything works.

Seems this is the reason:

For apps targeting Android 7.0, the Android framework enforces the StrictMode API policy that prohibits exposing file:// URIs outside your app. If an intent containing a file URI leaves your app, the app fails with a FileUriExposedException exception.

I hope an update of the AIR SDK will solve this soon.