You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Misc other useful utilities and customizations bundled with the main library
407
+
### BasicFileProvider (DocumentsProvider) post hoc interface
408
+
409
+
In the use case I have for this library, I expect users to select default folder paths and initial
410
+
script files from disk that will be run much later on after selection. In this context, it makes little
411
+
sense to queue up to much backend resources devoted to holding on to a pivot in the documents provider
412
+
that should service out the file contents until it is ready to be called. Thus, we will require a
413
+
mechanism to recall folder position and state from within the local ``DocumentsProvider`` class,
414
+
and then read (later more advanced functionality) out the file contents as a ``String`` or ``byte[]`` buffer,
415
+
either in small chunks, or all at once for sufficiently small sized text files (like small shell scripts).
416
+
417
+
With this in mind, there is a class in
418
+
[BasicFileProvider.java](https://github.com/maxieds/AndroidFilePickerLight/blob/master/AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/BasicFileProvider.java#L846) called
419
+
``DocumentPointer`` that allows for this sort of long after the fact post hoc recovery of file I/O
420
+
access once a user has selected the document path on disk (the ``Activity`` may restart, in fact,
421
+
before we need to recover the read access to the file by its path). It seems silly that Android 11 now
422
+
invokes having to go through this abstraction hoop when we are already returned a fully qualified path on disk.
423
+
Nonetheless, the permissions specs in upcoming API releases dictate getting used to this procedure now, and
424
+
better at this point than after a forced system upgrade that breaks my application in a year.
425
+
426
+
Here is an example that determines whether a file path (a priori known to point to a normal file, not directory)
427
+
is text based based on its mime type. Then, if it is, the second function below fetches its contents in ``String`` form:
0 commit comments