I like to raise to Euro 150, -, if I get a small piece of code
Sub btnCopyPDF_Click
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
wait for Activity_PermissionResult(Permission As String, Result As Boolean)
If Result Then
Log("Permission given. Check content")
Dim flist As List = File.ListFiles(File.Combine(File.DirRootExternal,"Download/"))
Log(flist)
Dim filetocopy As String = "profil_15.pdf"
End If
' Get DocumentDir
Dim docs As JavaObject = GetDocumentdDir(PersistantUri)
' Check if Destfolder Test already exists.
Dim chkTest As ExternalFile = Storage.FindFile(Storage.Root,"Test")
If chkTest.IsInitialized = False Then
'create the Folder "Test"
docs.RunMethod("createDirectory",Array("Test"))
End If
' Search the created Folder in the Storage Rootdir (we need to have a reference to it)
Dim Test As ExternalFile = Storage.FindFile(Storage.Root,"Test")
' define destfile
Dim destfile As ExternalFile = Storage.CreateNewFile(Test,filetocopy)
' Create an Outputstream to the destfile
Dim os As OutputStream = Storage.OpenOutputStream(destfile)
' Create an Inputstream from the Sourcefile to copy
Dim inpstr As InputStream = File.OpenInput(File.Combine(File.DirRootExternal,"Download/"),filetocopy)
' Copy file
File.Copy2(inpstr,os)
' Close Outputstream
os.Close
End Sub
As i do got a donation yesterday i expect you got it working. Thank you very much for the Donation!if it works, i will send the money immedetly
Logger verbunden mit: xxxxxxxxx
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
content://com.android.externalstorage.documents/tree/primary%3AWhatsApp%2FMedia%2FWhatsApp%20Video
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
Permission given. Check content
(ArrayList) [27.02.19_19.29_Anruf.01705883780.wav, unternehmensprofil_15.pdf, 2014-06-NAL-DE.pdf, Rechnung 1060788990 vom 02.03.2019.pdf, pt1007p.pdf]
Error occurred on line: 59 (Main)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at b4a.example3.main._getdocumentddir(main.java:683)
at b4a.example3.main$ResumableSub_btnCopyPDF_Click.resume(main.java:607)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:442)
at b4a.example3.main$ResumeMessage.run(main.java:306)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.IllegalArgumentException: Invalid URI:
at android.provider.DocumentsContract.getTreeDocumentId(DocumentsContract.java:927)
at android.support.v4.provider.DocumentFile.fromTreeUri(DocumentFile.java:138)
... 25 more
** Activity (main) Resume **
this is the list of the fioles in the folderPermission given. Check content
(ArrayList) [27.02.19_19.29_Anruf.01705883780.wav, unternehmensprofil_15.pdf, 2014-06-NAL-DE.pdf, Rechnung 1060788990 vom 02.03.2019.pdf, pt1007p.pdf]
Dim flist As List = File.ListFiles(File.Combine(File.DirRootExternal,"Download/"))
Dim filetocopy As String = "profil_15.pdf"
if I get a small piece of code, as already written, a file from an internal directory on the SD card copy, specifically main_memory/Download/profil_15.pdf to SD-card/Test/profile_15 .pdf (the targetfolder "Test" does not exist yet).
the error at the first run is because the example app is reading the stored document root in activity create.After the second test, I get no more errors
Sub btnCopyPDF_Click
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
wait for Activity_PermissionResult(Permission As String, Result As Boolean)
If Result Then
Log("Permission given. Check content")
Dim flist As List = File.ListFiles(File.Combine(File.DirRootExternal,"Download/"))
Log(flist)
Dim filetocopy As String = "unternehmensprofil_15.pdf"
End If
If File.Exists(File.DirInternal, FileName) Then
PersistantUri = File.ReadString(File.DirInternal, FileName)
Log($"PersistantUri=${PersistantUri}"$)
End If
' Get DocumentDir
Dim docs As JavaObject = GetDocumentdDir(PersistantUri)
' Check if Destfolder Test1 already exists.
Dim chkTest1 As ExternalFile = Storage.FindFile(Storage.Root,"Test1")
If chkTest1.IsInitialized = False Then
'create the Folder "Test1"
docs.RunMethod("createDirectory",Array("Test1"))
End If
' Search the created Folder in the Storage Rootdir (we need to have a reference to it)
Dim Test1 As ExternalFile = Storage.FindFile(Storage.Root,"Test1")
' define destfile
Dim destfile As ExternalFile = Storage.CreateNewFile(Test1,filetocopy)
' Create an Outputstream to the destfile
Dim os As OutputStream = Storage.OpenOutputStream(destfile)
' Create an Inputstream from the Sourcefile to copy
Dim inpstr As InputStream = File.OpenInput(File.Combine(File.DirRootExternal,"Download/"),filetocopy)
' Copy file
File.Copy2(inpstr,os)
' Close Outputstream
os.Close
End Sub
Based on this tree you selected the Folder "WhatsApp\Media\WhatsApp Video"PersistantUri=content://com.android.externalstorage.documents/tree/primary%3AWhatsApp%2FMedia%2FWhatsApp%20Video
This is the External SDCard in the Tablets SD-Slot.PersistantUri=content://com.android.externalstorage.documents/tree/4394-466B%3A
It is not a matter of finding the path. The sd card is not accessible until the user selects the folder.there is no other way to find the exact name of the SD card and folders on the SD card?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?