Android Question Save As cannot select other folders, and cannot change the file name

yshzsl

Member
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)
Please help me with this problem.
Thanks!
 

yshzsl

Member
问题可能出在其他地方。文件夹或文件名应该无关紧要。
Thanks for the answer, Erel.

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
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
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.
All of this shouldn't matter.

Do you see this behavior with the TextEditor example: [B4X] TextEditor - Save and load external files ?
 
Upvote 0

yshzsl

Member
Thanks,Erel

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.
 
Upvote 0

yshzsl

Member
Thanks for your attention, Erel.

I wrote a small project on the above issues,The compressed file has been uploaded.

Please help me and see where the problem is.
 

Attachments

  • testExcel.zip
    20.4 KB · Views: 54
Upvote 0

yshzsl

Member
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.

May I need any other additional libraries?
 

Attachments

  • aPOI.zip
    24.9 KB · Views: 44
  • Table.b4xlib
    28.6 KB · Views: 43
Upvote 0

yshzsl

Member
Thanks for the guidance, Erel.

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.

Thank you once again, Erel.
 
Upvote 0
Top