Android Question SaveAs - What is the explanation ?

Mauricio Pereira

Member
Licensed User
Longtime User
I have an application where a pdf file with the name "saida.pdf" is generated in the application folder.
To facilitate access we use the command [Wait For (SaveAs(File.OpenInput(File.DirInternal, "saida.pdf"), "application/octet-stream", "saida.pdf")) Complete (Success1 As Boolean] so that the file is saved in the Downloads folder.
In the debug version, it works without any problems, we can even change the file name to ex1.pdf, for example, when running SaveAs and the pdf is saved, without any problem, in the Downloads folder.
In the release version (without any change in relation to the debug version), if in SaveAs we change the name of the file to ex1.pdf, for example, the file is saved with zero size in the Downloads folder!
Where am I wrong ??
 

Mauricio Pereira

Member
Licensed User
Longtime User
In the release version, if I don't change, inside SaveAs, the name of the file, that is, I leave saida.pdf, it saves correctly.
For this reason I don't believe it is something in the program itself.
I will try to build a small project.
 
Upvote 0

Mauricio Pereira

Member
Licensed User
Longtime User
Erel,
I found an explanation: my tests were being done on an android 6 device.
I did the tests on a device with android 12 and the release version worked perfectly.
Is the SaveAs "function" restricted for some Android versions ?
 
Upvote 0

Mauricio Pereira

Member
Licensed User
Longtime User
The strange problem I reported in the initial message happened because I was using a Chinese version smartphone with a modified Android 6 rom.?
Later I tested the "SaveAs" function on smartphones and tablets with Android versions 5, 6, 7, 8, 11 and 12 and the routine worked perfectly.
The only caveat to be made is that when, using "SaveAs", a file called test.pdf, for example, is saved and then we save another file with the same name, it is saved as test.pdf(1).
This fact causes the second file to no longer be automatically recognized as a pdf file as the pdf(1) extension is not the default for pdf. The desirable thing is that it was saved as test(1).pdf
Obviously this happens with all types of files.
But this is not quite a problem.
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Also try to add Sleep(1000) code before SaveAs command.
Sleep function sometime solves the problems between fast consecutive file operations.
 
Upvote 0
Top