Only in Debug

Dogbonesix

Active Member
Licensed User
Longtime User
I have a nice little appointment application but will only run in DeBug.

I gather data in a Listview and on each record I add a line to a list. I use the list so I can print the list.

The app works fully and without error if I compile in DeBug but if I compile in Release mode I get the error below (I can't find Line 1302):

An error has occured in sub:
main_hc_responsesuccess
(Java line: 1302)
java.io.FileNotFoundException:
/mnt/sdcard/Documents/List.
txt (Permission denied)

The Code:
File.WriteList("/mnt/sdcard/Documents/", "List.txt", List1)

Any help will be deeply appreciated.
 

Cableguy

Expert
Licensed User
Longtime User
You are hard codding the SDCard folder when you have ways to have it from the system directory...
Use File.External, wich will get you straight to the root of the SDcard...
Check if the file exists before attempting to open it...
use If File.exists(..........)
 

Dogbonesix

Active Member
Licensed User
Longtime User
I'll give that a try.

How do use the "you have ways to have it from the system directory..."?

And why does it work fine in Debug and not in Release?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that you are posting in the wrong forum.

Change:
B4X:
File.WriteList("/mnt/sdcard/Documents/", "List.txt", List1)
To:
B4X:
File.WriteList(File.DirRootExternal, "Documents/List.txt", List1)

If you are using v2.50 then you can press on the List Permissions button in the compilation window and see the permissions added. You will see that in Debug mode the WRITE_EXTERNAL permission is added by the debugger. File.DirRootExternal will also add this permission (and is the correct way to access the external storage).
 
Top