To be compatible with android:targetSdkVersion="26" I tried to create and then download, save and then open/view files of various types. I can do so using rp As RuntimePermissions (thanks to Erels tutorial), but not yet in an external directory (to survive app uninstalls).
Is there another tutorial or example app from which an amateur like me could learn how to do it as I am still struggling with fileProvider and intents to open/show some files (e.g. PDF in Acrobat Reader).
Wouldn't it be nice to have these features already built in B4A?
Thanks Don, that was extremely fast.
Yes, I've seen all except the last two and when I followed the instructions in the second one and added the filePicker library I got this: Error parsing manifest script: Module FilePicker not found (Manifest Editor). Why?
In fact I was hoping to find all answers in a single example.
Thanks Erel,
I did read it all and downloaded all the samples, it's the understanding that hurts!
All examples use files in File.DirAssets, but I still don't know how to create a off-app directory and save downloaded files to it.
Before I just created it with RootPath = File.DirRootExternal&"/myStuff.dir", followed by File.makedir... How does it work with 26+ ?
john m.
There are two different things here. If you just need to write or read files for your app then use File.DirInternal or RuntimePermissions.GetSafeDirDefaultExternal (I would choose File.DirInternal).
I am obviously too dumb for this, perhaps some else can tell me how to create a new directory outside my app (e.g. Internal storage/Android/data/B4A.example plus sub-directories) and then save downloaded files to it.
Sub Activity_Create(FirstTime As Boolean)
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
Log("You can write wherever you like")
File.WriteString(File.DirRootExternal, "1.txt", "aaa")
Else
Log("you can only write in File.DirInternal or rp.GetSafeDirDefaultExternal")
End If
End Sub
You need to follow the example that was posted 8 times in this thread.
In that example the file is shared from rp.GetSafeDirDefaultExternal("shared'). This is declared in the manifest editor:
<external-files-path name="name" path="shared" />.
If you want to share from the root directly then change it to:
<external-path name="name" path="" />
If you have any specific question then please start a new thread.
This just proves that I was right in saying "I am obviously too dumb for this".
Thanks a lot, I'll try it again. I had the CheckAndRequest bit earlier in starter.bas which did nothing and I did not know about root dir vs. shared in manifest.
That was actually the first thing I did, but obviously was too dumb to catch and retain some details.
Sorry to have caused you all this trouble.
john m.