Hello everyone.
When I was saving the file using Save As,I cannot select another folder or change the file name.If I selected another folder or changed the scheduled saved file name,The saved file has no content, and the size is 0 KB.
If I do not change the folder or file name,It can be stored normally.
Code is as follows:
B4X:
Wait For (SaveAs(File.OpenInput(File.DirInternal, "book1.xls"), "application/octet-stream", "aaa.xls")) Complete (Success As Boolean)
Log("File saved successfully? " & Success)
I think I may not describe the problem in enough detail.
I use your Table class to extract the data from database,The table and the data can be displayed normally on the B4xPage page.
I want to export the table data and format to Excel,I tried two methods (one using aPOI, one using Excel class),Both methods can generate "book1.xls" normally.The above problems will arise when I save book1.xls as another file by Save As.
In the Save As code that you provide,The variable ion may be well defined before,But I don't know what type it is,So I define it as the Object type.I wonder if this is the problem.
B4X:
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
Dim ion As Object = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array(ion, i))
End Sub
I think I may not describe the problem in enough detail.
I use your Table class to extract the data from database,The table and the data can be displayed normally on the B4xPage page.
I want to export the table data and format to Excel,I tried two methods (one using aPOI, one using Excel class),Both methods can generate "book1.xls" normally.The above problems will arise when I save book1.xls as another file by Save As.
I tested the TextEditor example and it is able to save the files normally.
I copied the book1.txt file to the directory where the Excel file is located, I change the book1.xls to the book1.txt in the Save As statement ,And change of the target file to aaa.Txt,Code is as follows:
B4X:
Wait For (SaveAs(File.OpenInput(File.DirInternal, "book1.txt"), "text/plain", "aaa.txt")) Complete (Success As Boolean)
Log("File saved successfully? " & Success)
It is able to save the files normally,It works correctly, whether or not you select another folder or change the target file name.When I replace the book1.txt file with the book1.Xls file, making the code the same as before,It is not working properly again.
The Table libraries and the aPOI libraries I used have been uploaded,The additional libraries poi-3.12-android-a.jar and poi-ooxml-schemas-3.12-20150511-a.jar libraries can not be uploaded due to their large files.
Under your guidance, I found out where the problem is.In the original program, I did not refer to the ContentResolver library correctly, it is now working fine after the reference is re-added,It can store many types of files,It's amazing.