Android Question File.ExternalWritable..?

skipsy

Member
Licensed User
Longtime User
Hi all,
I'd like to prevent crashes when writing to an external storage.
I thought "File.ExternalWritable" could help but I don't understand something :
Which external storage is checked ??
I have a tablet with an SD card and a USB storage.
The USB not writable (FAT32 PC formated) so File.ExternalWritable returns TRUE.

Thks,
WW
 

skipsy

Member
Licensed User
Longtime User
Thk you for your reply.

If I understand...
ExternalWritable does not work for equipment having more than 2 storage (?) and the only way to avoid system error message is TRY/CATCH ?

WW
 
Upvote 0

skipsy

Member
Licensed User
Longtime User
There is definitely something I missunderstand !

Exploring the tablet I can see :
- /mnt/sdcard (explorer says : Internal memory)
- /mnt/extsd/sdcard1 (empty slot)
- /mnt/extsd/sdcard2 (empty slot)
- /mnt/usbhost/usb1 (empty slot)
- /mnt/usbhost/usb2 (USB key)

Somewhere in my app, I have
B4X:
File.MakeDir( File.DirRootExternal, "Saisie" )
The folder is created in /mnt/sdcard

So, when I call File.ExternalWritable I guess "/mnt/sdcard" is checked and that's why the app crashes when I try
to write on "/mnt/usbhost/usb2" with a read-only key.

Now, how to check if /mnt/usbhost/usb2 is writable ??

Thks Erel
 
Upvote 0

skipsy

Member
Licensed User
Longtime User
That's what I guessed :)

Thank you Erel
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If you are running Android 5+ on your device you can try my STORAGE library (see list of my libs in my signature)
 
Upvote 0

juvanum

Active Member
Licensed User
Longtime User
On my device Android 5+ FILE.EXTERNALWRITABLE works always but...
if the device is connected to the pc via usb cable the app is NOT able to write a file.
if the device is NOT connected to the pc via usb cable the app is able to write a file
 
Upvote 0
Top