SAF | SAF | Reactive Programming library
kandi X-RAY | SAF Summary
kandi X-RAY | SAF Summary
SAF(Simple Android Framework)最早的定位是一个简单的Android框架,现在它可以为Android App开发提供一系列基础性的组件。这个项目第一次提交到google code是2012年的3月26号,我已经断断续续做了5年多了。. 除了SAF自带的demo app外,魔窗的android demo app也使用了SAF,而且也是开源的.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Register an event bus
- Dispatch event
- Dispatches the result of an event
- Handle an event
- Get object by key
- Get byte array
- Get object from cache
- Get byte array
- Compares two strings
- Compares two numbers
- Reverses a string array
- Get phone work name
- Put object in editor
- Get an object from preferences
- Compacts a string
- Build the URL
- Get phone carrier
- Compare two strings
- Closes database manager
- Gets the finger printer
- Configure application
- Save model
- Get network generation string
- Re - reads a model from Parcelable
- Reads the database attached to the database
- Upgrade root permission
- Unregister event bus
SAF Key Features
SAF Examples and Code Snippets
Community Discussions
Trending Discussions on SAF
QUESTION
I wrote a simple search function that just looks for the value in the "name" field. How can I rewrite it if I want to search more fields at the same time?
...ANSWER
Answered 2022-Mar-29 at 15:25I understand you want to search across multiple fields in your form. You need to add another field to the form by which you want to search, and you must process the result of the response in the controller action.
QUESTION
How to achieve to listing all files (e.g. Media) inside hidden subdirectory i.e. folder name start with '.' e.g. "(.media)" after using SAF in Flutter/Dart?
I have used ACTION_OPEN_DOCUMENT_TREE to let the user choose a folder [So to avoid using MANAGE_EXTERNAL_STORAGE] but couldn't view i.e. Read the files inside the hidden subdirectory of the folder.
Permission Granted folder is media:
storage/emulated/0/internal storage/Android/media/matrix/.new/
Issue:
Not able to list all files inside subfolder .new
At the same time...
Able to access files (not folder) inside matrix subfolder
Also if I rename the subfolder ".new" to new I am able to list all the files inside that folder
I am using flutter/dart. For Shared Storage Permission, I have used Kotlin custom native code.
Kotlin Code:
...ANSWER
Answered 2022-Mar-07 at 11:43Finally I Found a package that can solve SAF issue ! Here is a link Visit
QUESTION
SAF(Storage Access Framework) have the constant DocumentsContract.Document.MIME_TYPE_DIR
Which is this string: vnd.android.document/directory as MIME Type for the directory.
MediaStore have anything like this for directory?
Below query print corresponding mime type for files and null for directories in Logcat.
...ANSWER
Answered 2022-Mar-05 at 13:35MediaStore have anything like this for directory?
No, sorry.
Is there any alternate way using MediaStore API to determine whether the item is a file or directory ?
MediaStore
only contains what you refer to as files.
QUESTION
A problem with saving a PDF file on Android has been bugging me for weeks, making every Google search I do result in a list of purple links.
I have attempted numerous approaches, but have only managed to save a PDF file using the built in PDF creator, which does not fulfill my purpose.
I have a number of questions that I seek an answer to, and hope some of you can help.
Question 1: Where should you save a PDF file you intend to share and then delete immediately after?
Q1 a) Is a ContentResolver & ContentProvider required, or is this only when sharing a 'directory' between apps?
Intuitively it makes most sense for me to save the PDF in the internal cache directory, share it from there and then delete it.
Question 2: What is the approach for storing files with backwards compatibility?
From what I have read, different SDK levels require different approaches for file storage, being:
- <= SDK 28 uses traditional storage methods, which is (using File API)?
- <= SDK 29 you should request permission for legacy storage, if using external storage
- >= SDK 30 Android enforces scoped storage
Using SAF (Storage Access Framework) seems to be the recommended way to store documents like PDFs. However, I don't intend to display a file picker to the user, when they are simply generating and sharing a PDF.
I am encountering this very generic exception, which occurs when iText closes the output stream. Below are some code examples and their resulting errors.
SDK 30 File API test
...ANSWER
Answered 2022-Feb-10 at 10:29You brought up a number of issues. This answer focuses on the actual errors you show.
The actual errors you show both cause a
QUESTION
In Android Studio:
This app must use COMTRADE files. The COMTRADE files are *.cfg *.dat and *.rio files. For example, (user.cfg, user.dat and user.rio). The main file is *.cfg file, so the user must browse by SAF to find *.cfg files, when the user select this file, the app must load other files ( *.dat and *.rio) automatically.
I can not use for android level 30
So I have to use Storage Access Framework, By below code the user browse *.cfg files and select a file like user.cfg
...ANSWER
Answered 2022-Jan-14 at 23:12Please help me how can I do this?
You cannot do this, at least by means of using ACTION_OPEN_DOCUMENT
, unless you ask the user to open each of your three documents in turn. Just because the user selected a .cfg
file does not mean that you have any rights to any other files, including those adjacent to it.
You could try using ACTION_OPEN_DOCUMENT_TREE
and let the user choose the document tree that contains your desired files. From there, you can:
- Use
DocumentFile.fromTreeUri()
to get aDocumentFile
representing the tree - Call
listFiles()
on thatDocumentFile
to get the direct contents of that tree, in the form of a list ofDocumentFile
objects - Call
getName()
on each of those to get their display names, then see which names have your desired file extensions and matching base names (foo.cfg
andfoo.rio
andfoo.dat
) - For those that you want to use, call
getUri()
on theDocumentFile
to get aUri
to use withContentResolver
andopenInputStream()
to read in the content
QUESTION
I am on Android 11. I just want to be able to create a file in /storage/emulated/0/Download
directory on my phone. So, this is the public Download folder that I need to create a file on.
I don't need access to read/modify/delete other files in /storage/emulated/0/Download
. i just want my app to be able to create and replace a file of its own at /storage/emulated/0/Download
. Thats it!
Question:
- Do I need to go by the Storage Access Framework for this?
- Do I need any special permission for this?
- Or is it possible get access to
/storage/emulated/0/Documents
without going through the hassle of Android SAF?
My app is able to create a file at /storage/emulated/0/Download
using Android 10 but it fails to do that since Android 11.
My use case is very simple. I just want to create a file at /storage/emulated/0/Download
and keep appending more data to the file by replacing it with a new one from time to time.
Running the following code on Android 11 fails for me:
...ANSWER
Answered 2021-Dec-06 at 19:38Do I need to go by the Storage Access Framework for this?
No.
Do I need any special permission for this?
No, though you will need WRITE_EXTERNAL_STORAGE
for older devices.
Or is it possible get access to /storage/emulated/0/Documents without going through the hassle of Android SAF?
Environment.getExternalStoragePublicDirectory()
is being undeprecated, so it is safe to use that to access Environment.DIRECTORY_DOWNLOADS
. That should give you the same access that you have with MediaStore
:
You can create files there
You can read and write your own files1 there
You have no access to other apps' files there
1 For the purposes of this bullet, "your own" refers to your current app installation — if the user uninstalls and reinstalls your app, files from the old installation of your app are no longer considered to be "your own".
So, for example, this activity works just fine without any permissions in a targetSdkVersion 31
project:
QUESTION
I'm currently migrating an Android app to Scoped Storage. Moving away from java.io.file
is a real nightmare, and feels much of a drawback to me. I'm currently trying to understand if paths returned by getExternalMediaDirs()
can effectively be used with direct file paths.
After asking user to select a given folder
...ANSWER
Answered 2021-Nov-26 at 06:36Yes, because after granting permissions you have access to Content Scheme Uri
of that specific folder not file system paths so you will be unable to list java.io.File objects using this Uri.
But you can use it to listFiles()
which will return you a list of DocumentFile. You can then use these DocumentFile
objects to get Uri
of that specific file using documentFile.getUri() . Using that Uri
you can easily perform basic operations like display,copy,delete,share
on that file.
Below is an example of listing files from a folder of other app.
I am skiping take permissions part of code assuming that you already have permissions to access that other app's folder
In this example i am listing files from Android/media/com.whatsapp/WhatsApp/Media/.Statuses
DOC Ids are
QUESTION
For over a week I try to solve weird problem. When i try to get file uri's using SAF and ACTION_OPEN_DOCUMENT and use takePersistableUriPermission() method on them I get SecurityException :
...ANSWER
Answered 2021-Nov-17 at 22:16On Android 10 and lower, there is a limit of 128 persisted permission grants: https://issuetracker.google.com/issues/149315521
That limit was raised to 512 for Android 11; I do not know if Android 12 raised it further.
QUESTION
The app sends the user to SAF picker with ACTION_OPEN_DOCUMENT_TREE:
...ANSWER
Answered 2021-Nov-16 at 07:11Uri dirUriParsed = Uri.parse(Uri.decode(result))
Try:
QUESTION
I am using the Storage Access Framework (SAF) :
...ANSWER
Answered 2021-Oct-19 at 11:11where this extras to configure certain SAF options are documented?
Most are not documented. The few that are will be documented either on ACTION_OPEN_DOCUMENT
or will appear as other defined constants on Intent
.
And, as always, using undocumented Intent
extras may lead to inconsistent behavior across devices and OS versions, as Google is not considering those extras to be part of a public, supported API.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SAF
You can use SAF like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the SAF component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page