I'm working with one of the many Android FFmpeg libraries on GitHub, which each involve an NDK wrapper around a C binary. I'm trying to give other apps access to the video file I have edited with FFmpeg (and saved in External Storage), but at least on Android 6.0, the new permissions system prevents them from being able to access the shared file unless they themselves have the External Storage permission granted. The solution here would be to use content providers to open up a directory for other apps to access. However...
My FFmpeg binary is contained within the app's data directory, but it fails when I try to access or modify a video file saved there. As mentioned above, it has no problem accessing external storage.
Is there a way to give FFmpeg access to my app's data directory, giving it read and write permissions? Would naming the library with the same package name do the trick?
Any ideas? Thanks for any advice!
Related
My app is letting users select audio files with an Intent.ACTION_OPEN_DOCUMENT from within their document hierarchy (ordinarily on internal storage and not in my app's storage). The files, once selected, are then processed natively in OBOE.
I have JNI working. I can open the file in java and copy the bytecode over to native.
But if I want to open a file directly in the Native code then I must set the app to ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION. This seems a bit clumsy, it is probably because I'm sending the file path - using getPath() on the uri - to native and using fopen()?
Is it possible for me to inherit the permission from the java side to open the file natively without requiring All Files Acess permission? I tried sending a FileDescriptor over but that wasn't successful, although could have been my implementation.
I am trying to make a file manager type application and I want to access all files. I know it will need MANAGE_EXTERNAL_STORAGE permission but I am not able to figure out which api should I use.
I am trying to make a file manager type application and I want to access all files.
I'll recommend you to start from here : Manage all files on a storage device (keep in mind you cannot write internal storage on a non-rooted device).
I am not able to figure out which api should I use.
MediaStore might suit your needs (even if your question is a bit generic) , so give it a reading to Access media files from shared storage.
We are writing a C++ app that is cross compiled for Android. This app uses native libraries (namely gdal and Qt) to read and write files.
These files often have references to each other (e.g. a xml file, referencing other files next to it; or shapefiles, where multiple files have a common base name). The above mentioned libraries need to be able to open files by path (fopen(name)) to get access to all information.
Common use cases are:
download a zip file using a browser, unzip it using an file manage (e.g. amaze) and open the contents in our app
use a file sharing app like nextcloud, syncthing, ... to sync a folder. The files in this folder are then edited by our app.
Since API level 30 Google PlayStore restricts file access and only allows unrestricted direct file access in an specific app-specific directory.
In shared folders (e.g. the Download folder, root folders in external storage devices, etc.) only a subset of file types is accessible through direct file access.
The Acess media files from shared storage documentation mentions
If you don't have any storage-related permissions, you can access files in your app-specific directory, as well as media files that are attributed to your app, using the File API.
Media files in our tests include images, videos, ... but not the file types required here (.dbf, .shp, .qgs).
There is also the storage access framework where a DocumentProvider can be used to stream data of individual files and intents like OPEN_DOCUMENT_TREE these will however generate access via URI which is not compatible with native fopen(name) calls.
The only option we found capable of opening files by name (through native labraries) is to use the all files permission (MANAGE_EXTERNAL_STORAGE). This works well but needs to be whitelisted to be published on Google Play Store.
Google support suggests using the system file picker (and sometimes extends the suggestion to "or other privacy friendly approaches").
Q: If your libraries could work with paths before then they still can. Where is it that the problem starts?
A: On Android 11, without a MANAGE_EXTERNAL_STORAGE permission, what we have seen in our multiple tests is that directly opening non-media files in shared locations via their path strings is not working anymore.
The file opening fails.
We have also noticed that doing a directory listing (using Qt APIs) only shows media file extensions, skipping all other types.
How is it possible to open files by file path (string) in shared locations with native libraries without the all files permission (MANAGE_EXTERNAL_STORAGE)?
I copy a file from USB to my SamSung S7 tablet using My Files app shipped with my tablet. I can find this file under /data using My Files app.
I believe this file is stored in the shared external storage. As pointed in
https://developer.android.com/training/data-storage
I need Android Storage Access Framework to access this file.
I want to access this file with my own app and I need to know the URL. What's the URL look like?
Thanks.
YL
A file URL looks like this in Android and you can use this type of URL to access files:
file:///path/to/foo.txt
file:// is used to refer to URL pointing to a world-readable file.
You can get path to directory from one of these getExternalFilesDir() or getExternalCacheDir() or getExternalMediaDirs(). Hence, getExternalStorageDirectory is deprecated and no longer recommended for use. (Read more here)
Lastly, make sure you have made permission to access: WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE
Let me know if you have any questions. Thanks.
My application generates some .csv files while running and these files are placed inside Android File system. These files are accessible outside the application also(as i can open these files in text editor and modify...)
Now I want that only my application should be able to read/write into these files.
Please help me in achieving this.
Thanks a lot.
These files are accessible outside the application also(as i can open these files in text editor and modify...)
Presumably that means you are placing them on external storage.
Now I want that only my application should be able to read/write into these files
Place the files on internal storage. This will prevent ordinary Android users from accessing the files except via your app.
Owners of rooted devices can get at those files, and if you are concerned about that scenario, then do not create any files at all, as owners of rooted devices can get to anything.
Also see article here: http://developer.android.com/training/basics/data-storage/files.html
It informs about internal vs external storage as well as making data public vs private for your app.