I'm trying to put firebird embedded running on android.
The problem is that fb put temporary files on /data/local/tmp.
That folder don't seems to have write permissions, at least on Android 6, and fb fails to start.
Do android have a good place to put this files?
That place must be available globally and can't be cleaned by external services.
Regards
jGoncalves
That place must be available globally and can't be cleaned by external
services.
Those two things are mutually exclusive.
You can either put it in external storage where any app can read and write it (if they've been granted the respective permissions), or you can put it in app private storage where only your app can read it.
If you want to export data from a database to other apps, the right way is to wrap it with a content provider and publish your content provider interface to other interested apps.
I don't know Firebase, but I'm guessing that it can't support multiple processes reading and writing to the same DB file.
Related
Trying to make some sense of this complete mess of scoped storage.
So I'm storing some files (logs) generated by App A inside the Download folder.
I'm using Mediastore/ContentResolver and no problems with that either for read or write access as long as it's from App A.
But then App B needs to read these files and here comes the problem.
Same way using Mediastore/ContentResolver but the files seem invisible for queries.
Download is supposed to be a Shared Storage, but files are indeed generated as -rw-rw--- which means no permission for others which could explaind why App B does not sees files from App A if they are not in the same group.
Would the Storage Access Framework method work around this?
Thi not tried it yet because poping system window's is definitely not something I wanted as a user experience for my App.
Thanks.
If the second app has 'all files access' with MANAGE_EXTERNAL_STORAGE it can also list the files of the first app.
Otherwise you can let the user of the second app pick those files with ACTION_OPEN_DOCUMENT of Storage Access Framework.
You better store your files in a sub directory as then second app can pick complete directory with ACTION_OPEN_DOCUMENT_TREE and list all the files.
Scenario
I've two apps, one is the Tracker App which records the incoming and outgoing calls and zipped these files, and sends the file path to the Main App via Inter-Process Communication which uploads these files to the server.
Now I'm upgrading both apps to Android 11. In Tracker App, I'm using MediaStore.Files API to save files and trying to read these files using the file path in Main App. While reading file File.canRead() returns false in Main App. Even I tried MediaStore API to read these files it returns empty Cursor.
Here I've few questions.
Can I read files that are created by the Others app on Android 11? I read somewhere that you can't access others apps files in Android 11.
Is my app eligible for MANAGE_EXTERNAL_STORAGE permission to access all files in storage?
What will be the best way to handle this scenario?
Can ``` Storage Access Framework `` help me to handle this scenario?
I'm saving files in the public directory Documents/AppData/Audio. Please give me working links regarding this. Any help will be appreciated. Thanks
As in Android 11 MediaStore API only returns media files.
so, i will answer your questions related to it.
Can I read files that are created by the Others app on Android 11? I
read somewhere that you can't access others apps files in Android 11.
No! you can't access the files created by other application that are stored in personal storage of that specific app.
Is my app eligible for MANAGE_EXTERNAL_STORAGE permission to access
all files in storage?
As far as i understand, your app doesn't required external storage to store the data it can be also done in private storage where you can read or write your data. and if your app is eligible for this permission anyway still you can't use it as of now. it's been suggested by official web rather then asking this permission make target API 29 and use android:requestLegacyExternalStorage="true" in your manifest.
click here to read about it.
What will be the best way to handle this scenario?
Rather using external audio path you can use you app specific folder to store the archive that you are creating.
Can ``` Storage Access Framework `` help me to handle this scenario?
I don't have much idea about how IPC work between two apps so i can't tell exactly that it will be better to use Storage framework.
I've two apps, one is the Tracker App which records the incoming and outgoing calls and zipped these files, and sends the file path to the Main App via Inter-Process Communication which uploads these files to the server.
That seems overly complex.
Can I read files that are created by the Others app on Android 11?
Technically, you are not writing a file. You are creating an entry in MediaStore.Files. Other apps cannot read entries that you create in MediaStore.Files.
Is my app eligible for MANAGE_EXTERNAL_STORAGE permission to access all files in storage?
We are not Google. We have no way of answering that. It would surprise me greatly, though, if they considered your app to be eligible for this.
What will be the best way to handle this scenario?
Well, IMHO, the best way by far would be to have one app, not two. But I am assuming you are not in position to change that at this time.
If so, then:
Have the "tracker" app write the content to files in a filesystem directory that the app can write to. Mostly, that will be via methods on Context, such as getFilesDir() or getExternalCacheDir().
Have the "tracker" app use FileProvider to serve files from that directory, and use FileProvider.getUriForFile() to get a Uri pointing to that file.
Have the "tracker" app invoke your "main" app via some Intent-based mechanism (startActivity(), startService(), sendBroadcast(), etc.). Put the Uri from the previous bullet into that Intent, and add FLAG_GRANT_READ_URI_PERMISSION to that Intent.
Have the "main" app read the content using a ContentResolver and openInputStream(), passing in the Uri that it extracts from its copy of the Intent.
Can ``` Storage Access Framework `` help me to handle this scenario?
You could have the user, in each app, use the Storage Access Framework. For example, you could use ACTION_OPEN_DOCUMENT_TREE in each app, hoping that the user would choose the same tree in each app. Personally, I would use FileProvider, as it does not require user interaction and does not require the user to make good choices.
The receiving app can use SAF to let the user pick your directory.
Or more standard: you have files so you build your own file/content provider to serve your files.
And if you use inter process communication(how by the way) you could serve your files one by one using the uri from mediastore and FileProvider.
We developed two android applications, one that creates a folder with multiple files (.xml /.txt /.db) and another one that needs to access these files. Both application needs read and write authorizations to these files.
Before Android 11, we use to store these files in the app-specific external storage (Android/data/com...), the other app was able to read/write those files.
With Android 11 and enforcement of scoped storage, secondary app cannot access the primary app folder.
Is there any way of creating a "public" directory that store all shareable files ?
While searching, i found about the FileProvider component but i don't know if it will work despite scoped storage.
I'm aware of the new authorization MANAGE_EXTERNAL_STORAGE, but if i use this i'm afraid that playstore might reject my apps.
Despite all my researches, i didn't find a solution to my problem.
Thank you for your help.
On Android 11:
Make your own directory in one of the public directories like Documents, DCIM, Pictures, Alarms and so on, and put your files there.
I am trying to build an application in which user can share media files over internet. Now I am confused that there are lots of functions in the library through which we can get access to files stored in the users storage. I don't know which to use..
In Context#getExternalFilesDir(String) documentation, they insist using Environment.getExternalStoragePublicDirectory() to write media that must be shared with other apps and that must be kept even after uninstall of an app. But in Environment#getExternalStoragePublicDirectory(string) documentation, they say that this method is deprecated, and recommend using alternatives such as Context.getExternalFilesDir(). If that was deprecated in first place, then why did they insist to use that method. What is the reason behind them playing these tricks, I don't understand.
Please suggest me a function that is: not deprecated, should return a directory where I can read and write, media stored there should be visible to other apps, they must not be deleted when user uninstalles this app.
I believe you are looking for Shared Storage.
Android file system and storage changed a lot during this years.
Data and file storage overview
According to the Android Development Documentation, you can't just open any file you want ("Open a private file associated with this Context's application package for writing.").
What, however, when I want my application to read files created by other applications? Let's say I have a file in /data/app_1/hello.txt, but my application has nothing to do with it because my app is called app_2, how would I still be able to open this file (and write back to it)?
You can't in general, Applications on Android are isolated and sparated. A application can only write and read its own files.
There are exceptions: As the documentation states: "It's possible to arrange for two applications to share the same Linux user ID, in which case they are able to access each other's files. To conserve system resources, applications with the same user ID can also arrange to run in the same Linux process and share the same VM (the applications must also be signed with the same certificate)."
Another possiblity is that the files are created as "world readable" so that every application can read it.
So to summarize and come back to your question: If you can not modify "my_app_1" then it is impossible. Of you can modify both applications choose one of the solutions above.
Two options:
If you are designing both applications and want to share the file, keep it somewhere else (for example - external storage) or make it world readable.
If you are trying to read another app's file - well, you shouldn't, that's a key element in the android security architecture.