Android Question Save As to Copy a File is Zero Size

mackrackit

Member
Licensed User
Longtime User
Hi,

I am using the example here as a base. SaveAs Code Snippet I am not using pages, replaced GetBA per instructions.
Using a Galaxy Tab A7 Lite with Android version 13 for a testing device. Compiling to SDK version 33.

The problem I am having is the file saved using SaveAs is always 0 B in size.

I can verify that there is data in the file with
Read File:
Sub ReadString
    MsgboxAsync(File.ReadString(File.DirInternal, "84_Text.txt"), "")
End Sub
The SaveAs
Save Button:
Private Sub Button1_Click
    Wait For (SaveAs(File.OpenInput(File.DirInternal, "84_Text.txt"), "text/plain", "84_Text.txt")) Complete (Success As Boolean)
    Log("File saved successfully? " & Success)
End Sub
Also tried "application/octet-stream" without a difference.
Tried different locations when saving and tried changing and not changing the file name, alway creates a file 0 B in size without content.
 
Solution
Hi drgottjr,

I started from scratch with a small project that only wrote a text file and the SaveAs function. Same results.
On both attempts this warning was present.
Undeclared variable 'ion'. (warning #8)
I have read statements similar to " it is only a warning, not to worry". Not this time.
I looked at the text editor tutorial and saw where ion was declared.
Private ion As Object
Added that to my project and Presto! It works!

Attached is the simple test program if anyone is interested.

drgottjr

Expert
Licensed User
Longtime User
the saveas snippet works fine. i just tried it to make sure something hadn't changed while i was sleeping. you've done something that you haven't shown to us.
 
Upvote 0

mackrackit

Member
Licensed User
Longtime User
Hi drgottjr,

I started from scratch with a small project that only wrote a text file and the SaveAs function. Same results.
On both attempts this warning was present.
Undeclared variable 'ion'. (warning #8)
I have read statements similar to " it is only a warning, not to worry". Not this time.
I looked at the text editor tutorial and saw where ion was declared.
Private ion As Object
Added that to my project and Presto! It works!

Attached is the simple test program if anyone is interested.
 

Attachments

  • SaveAs_Test.zip
    9.9 KB · Views: 38
Upvote 0
Solution
Top