File not open #139
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Android 10 framework does not allow you to retain the file access once the app is killed, that's why Suppose that your file is in storageHelper.onStorageAccessGranted = { _, root ->
Toast.makeText(
this,
getString(com.anggrayudi.storage.R.string.ss_selecting_root_path_success_without_open_folder_picker, root.getAbsolutePath(this)),
Toast.LENGTH_SHORT
).show()
}
storageHelper.requestStorageAccess(initialPath = FileFullPath(this, "/storage/emulated/0/Pictures")) After the user granted access to your request, then val picture = DocumentFileCompat.fromFullPath(this, "/storage/emulated/0/Pictures/selfie.jpg") |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks. |
Beta Was this translation helpful? Give feedback.
Android 10 framework does not allow you to retain the file access once the app is killed, that's why
DocumentFileCompat.fromFullPath()
returnednull
. So, storing the file path into a database is not a good idea, unless you have the URI access granted for its parent folder. So, if you want to keep the file access in long-term purpose, you will need to request access to its parent folder first. It can be done viaSimpleStorage#requestStorageAccess()
.Suppose that your file is in
/storage/emulated/0/Pictures/selfie.jpg
, then you need to request access for/storage/emulated/0/Pictures
, so accessingselfie.jpg
will be possible in the future. Example:storageHelper.onStorageAccessGranted = { _,…