SAF | Simple Archive Format - A minimal, stream-friendly format for file/object archiving | Continuous Backup library
kandi X-RAY | SAF Summary
kandi X-RAY | SAF Summary
The Simple Archive Format, or SAF, is a simple, lightweight, extendable file archive format designed by the Surface Automation Team. It has similar functionality to tar or cpio.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of SAF
SAF Key Features
SAF Examples and Code Snippets
Community Discussions
Trending Discussions on SAF
QUESTION
I have a custom DocumentsProvider implementation that works flawlessly for a user to choose photos or videos for use by the app, as long as the Android API is 26 or greater. Using APIs 21-25 I get a security error similar to what is described in this SO post. However I am already doing everything mentioned in that post as a solution.
Manifest entry:
...ANSWER
Answered 2021-Jun-11 at 03:39There isn't anything wrong with your implementation of DocumentsProvider
, it's the expected behavior on API 19-25 when working with SAF.
Even if you get a SecurityException
while trying to take persistable URI permission you'd still always have access to URIs exposed from your own DocumentsProvider
.
Thus it'd be a good idea to catch and ignore the SecurityException
specially from your own URIs.
Note: If your app contains a DocumentsProvider and also persists URIs returned from ACTION_OPEN_DOCUMENT, ACTION_OPEN_DOCUMENT_TREE, or ACTION_CREATE_DOCUMENT, be aware that you won’t be able to persist access to your own URIs via takePersistableUriPermission() — despite it failing with a SecurityException, you’ll always have access to URIs from your own app. You can add the boolean EXTRA_EXCLUDE_SELF to your Intents if you want to hide your own DocumentsProvider(s) on API 23+ devices for any of these actions.
Here's a note from official Android Developers blog that confirms this behavior - https://medium.com/androiddevelopers/building-a-documentsprovider-f7f2fb38e86a
QUESTION
I have two files
File_A.txt
...ANSWER
Answered 2021-Apr-17 at 11:45This awk
should work for you:
QUESTION
I have a multi line text from where i want to match the text between the word "Description Amount" and a random digit with commas as delimiter.
Example Input:
ANSWER
Answered 2021-Mar-14 at 11:59If the digit is at the start of the line, you might use
QUESTION
There are various storage restrictions on Android 10 and 11, which also includes a new permission (MANAGE_EXTERNAL_STORAGE) to access all files (yet it doesn't allow access to really all files ) while the previous storage permission got reduced to grant access just to media files :
- Apps can reach the "media" sub folder freely.
- Apps can never reach "data" sub folder and especially the content.
- For "obb" folder, if the app was allowed to install apps, it can reach it (to copy files to there). Otherwise it can't.
- Using USB or root, you could still reach them, and as an end user you can reach them via the built-in file-manager app "Files".
I've noticed an app that somehow overcome this limitation (here) called "X-plore": Once you enter "Android/data" folder, it asks you to grant access to it (directly using SAF, somehow), and when you grant it, you can access everything in all folders of "Android" folder.
This means there might still be a way to reach it, but problem is that I couldn't make a sample that does the same, for some reason.
What I've found and triedIt seems this app targets API 29 (Android 10), and that it doesn't use the new permission yet, and that it has the flag requestLegacyExternalStorage. I don't know if the same trick they use will work when targeting API 30, but I can say that on my case, running on Pixel 4 with Android 11, it works fine.
So I tried to do the same:
I made a sample POC that targets Android API 29, has storage permissions (of all kinds) granted, including the legacy flag.
I tried to request access directly to "Android" folder (based on here), which sadly didn't work as it goes to some reason (kept going to DCIM folder, no idea why) :
ANSWER
Answered 2021-Mar-03 at 21:27Well, I tried this code and it works on Android API 29, Samsung Galaxy 20FE:
QUESTION
I have the following entity:
...ANSWER
Answered 2021-Feb-23 at 09:20Selecting each value explicitly and prefixing the joined tables seems to have worked (though I'm not 100% sure why):
QUESTION
I have two Uri
from different files with schema "content" obtained by the Android SAF API and I need to copy exif information from one file to the other. The destination file was created by my app so I have granted write access to it.
With the ContentResolver
I can obtain an InputStream
that I can use to instantiate an ExifInterface
from wich I can extract the exif from the source Uri
:
ANSWER
Answered 2021-Jan-17 at 00:09Since no one came with an answer but thanks to @blackapps comment I was able to find out the solution myself. I will post it here if someone else gets to this post searching for the answer for this same question.
It turns out that the ExifInterface
has a constructor that receives a FileDescriptor
as a parameter and it is possible to open a FileDescriptor
from an Uri
by using the ContentResolver
. Then the solution is easy and the only extra care one needs in order to successfully open the FileDescriptor
is to use the "rw" mode since the ExifInterface
will need to read and write info and not just only write.
Here goes a sample code:
QUESTION
I'm looking forward to build a File Explorer app but I'm shocked with what I found on I do need full read/write permission and access to everything.
So as they state here:
Declare the MANAGE_EXTERNAL_STORAGE permission in the manifest.
Use the ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent action to direct users to a system settings page where they can enable the following option for your app
To determine whether your app has been granted the MANAGE_EXTERNAL_STORAGE permission, call Environment.isExternalStorageManager().
Now I can access to the root folder "/storage/emulated/0/" via Environment.getExternalStoragePublicDirectory(path)
and then file.listFiles()
But when I want to access to Downloads folder I can't, I've looked at SAF but I'd have to use like ACTIONS and I just want to explore through folders, then I looked at MediaStore but there's not a clear example of how I could use it here since I'm trying to get the files but cursor.moveToNext()
or cursor.moveToFirst()
returns false
Here's the code I've used
...ANSWER
Answered 2020-Dec-25 at 17:24Answering some of your questions:
Do I need other permissions for the purpose of reading files?
No, as it's stated here, you've got all the possible file-related permissions.
What am I missing on this MediaStore query? Why it doesn't provide me the files of download?
Download is a kind of special case. Here at the very bottom of the section it says
In particular, if your app wants to access a file within the MediaStore.Downloads collection that your app didn't create, you must use the Storage Access Framework.
And even using SAF you will not be able to access all files in Download directory. So you can access a single file picked by user, but you cannot list the content of the directory.
Generally, as it's stated here, having the MANAGE_EXTERNAL_STORAGE
permission granted, you can access all non-restricted files using both MediaStore
and file paths. Both ways should give the same result.
QUESTION
I am using the Storage Access Framework in android for selecting images and uploading in my app. Before uploading these images to my server, i also process these images (resizing).
However, in the URI returned by the SAF, there is no extension appended, i don't know how to get extension of the file. I need to differentiate between png and jpeg. How can i achieve that ?
Example uri returned from SAF - content://com.android.providers.media.documents/document/image%3A245309
My code is something like this
...ANSWER
Answered 2020-Jul-24 at 20:55I need to differentiate between png and jpeg. How can i achieve that ?
Call getType()
on a ContentResolver
, passing in the Uri
. This will return the MIME type associated with the content, such as image/png
.
QUESTION
I'm trying to save a text file using SAF (Storage Access Framework) but I can't control where it should be saved, I used this method from the Documentation as follows:
...ANSWER
Answered 2020-Nov-25 at 11:54Quoting the documentation for EXTRA_INITIAL_URI
:
[The extra] should specify a document URI or a tree URI with document ID.
A "document URI" is one that you obtained previously from ACTION_OPEN_DOCUMENT
or ACTION_CREATE_DOCUMENT
. A "tree URI" is one that you obtained previously from ACTION_OPEN_DOCUMENT_TREE
. Uri.parse()
is neither of those.
QUESTION
I am developing a food cart function where I am adding products to the cart. My cart is an Array type and the product is an object with key-values. The problem I am facing is, whenever I am trying to add a new product with a different value for a similar key, it overwrites the value of the same key for the old product as well. As per my understanding, an array is just a reference pointing to my product object but I want to know, what is the best method to resolve this issue? Here is how my code structure looks like:
component.ts
...ANSWER
Answered 2020-Nov-23 at 20:51Clone the product object before modifying it
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SAF
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