No SD Card – No Error

Discussions about creating CAPI applications to run on Android devices
Forum rules
New release: CSPro 8.0
Post Reply
leulae
Posts: 46
Joined: December 16th, 2016, 5:51 am

No SD Card – No Error

Post by leulae »

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: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: No SD Card – No Error

Post by Gregory Martin »

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

Re: No SD Card – No Error

Post by josh »

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

Re: No SD Card – No Error

Post by leulae »

Thank you all for your guidance

Leulae
Post Reply