Discussions about creating CAPI applications to run on Android devices
leulae
Posts: 46 Joined: December 16th, 2016, 5:51 am
Post
by leulae » March 5th, 2018, 11:55 am
Dear all,
pathname(CSEntryExternal) – No SD Card – No Error
I wrote backup operation for Android with the help of pathname(CSEntryExternal) function.
Code: Select all
string backupToSD = pathname(CSEntryExternal) + maketext("myfolder/Backup%d",timestamp());
filecopy(pathname(Application) + "Data/filename.DAT",backupToSD);
It Backups to SD Card
The problem is,
when there is no SD card it does not give an error.
Need to detect a method to check/verify SD card present or not
Please help on this regard
Thanks in advance
Leulae
Gregory Martin
Posts: 1807 Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC
Post
by Gregory Martin » March 5th, 2018, 2:34 pm
I don't have a device with a SD card so I can't test this, but the dircreate function should return 1 if a directory exists, so this might work:
if dircreate (pathname (CSEntryExternal)) = 0 then
errmsg ("A SD card is not present." );
endif ;
josh
Posts: 2399 Joined: May 5th, 2014, 12:49 pm
Location: Washington DC
Post
by josh » March 5th, 2018, 5:27 pm
Did you try checking the value of pathname(CSEntryExternal) to make sure it is not empty? I think it should return either and empty string or "<invalid path>" if there is no SD card. You could check this with code like:
if pathname (CSEntryExternal) = "" or pathname (CSEntryExternal) = "<invalid path>" then
errmsg ( "Please insert an SD card" );
endif ;
Also the filecopy should return default if there is no SD card so you could check that:
if filecopy ( pathname (Application) + "Data/filename.DAT" ,backupToSD) = default then
errmsg ( "Please insert an SD card" );
endif ;
leulae
Posts: 46 Joined: December 16th, 2016, 5:51 am
Post
by leulae » March 7th, 2018, 3:46 am
Thank you all for your guidance
Leulae