Im using ArchiverPlus. It zips but can't save it for some strange reason. I checked the zip bytes = 3603. result = 0. File saved does not get logged. it saves in the download section i choose with 0 bytes??
B4X:
Dim Arc As ArchiverPlusZip
Arc.ZipCompression = True
Arc.ZipExecutionMode = Arc.ZIP_EXECMODE_ASYNCHRONOUS
Arc.AddFolderToZip(File.DirInternal & "/TempBackup/", File.DirInternal & "/Test.zip", "ZIP")
Wait For ZIP_ZipResult(Result As Int, ErrorMsg As String)
Log(Result)
If File.Exists(File.DirInternal, "/Test.zip") Then
Log(File.Size(File.DirInternal, "/Test.zip"))
Log("its there!!!!!!")
End If
Wait For (SaveAs(File.OpenInput(File.DirInternal, "/Test.zip"), "application/zip", "test.zip")) Complete (Success As Boolean)
Log("File saved successfully? " & Success)
B4X:
Sub SaveAs (Source As InputStream, MimeType As String, Title As String) As ResumableSub
Dim intent As Intent
intent.Initialize("android.intent.action.CREATE_DOCUMENT", "")
intent.AddCategory("android.intent.category.OPENABLE")
intent.PutExtra("android.intent.extra.TITLE", Title)
intent.SetType(MimeType)
StartActivityForResult(intent)
Wait For ion_Event (MethodName As String, Args() As Object)
If -1 = Args(0) Then 'resultCode = RESULT_OK
Dim result As Intent = Args(1)
Dim jo As JavaObject = result
Dim ctxt As JavaObject
Dim ContentResolver As JavaObject = ctxt.InitializeContext.RunMethodJO("getContentResolver", Null)
Dim out As OutputStream = ContentResolver.RunMethod("openOutputStream", Array(jo.RunMethod("getData", Null), "wt")) 'wt = Write+Trim
File.Copy2(Source, out)
out.Close
Return True
End If
Return False
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
Dim ion As String
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject = Me
Return jo.RunMethod("getBA", Null)
End Sub