Page 1 of 1

Accessing an external memory card

Posted: May 28th, 2019, 8:07 pm
by AriSilva
Hi folks,
I need to save a backup of my csdb file into an external memory card that is connected to the tablet.
I was able to do that in an old tablet samsung A4 that I use for tests, with the following command lines:

string bkcsdb = maketext ("/storage/extSdCard/TCA");
dircreate(bkcsdb);
filecopy("/storage/sdcard0/csentry/TCA_10_Entrevista.csdb",bkcsdb);

But it did not work with the new samsung A06 that we are using for real.
I know that this is outside the realm of this forum, since every tablet has a different address name for the external cards, but do you know where I could find card address in the samsung tablet A06? I tried "my files" app but it does not show any name.
Best
Ari

Re: Accessing an external memory card

Posted: May 29th, 2019, 2:54 am
by josh
For security reasons recent versions of Android don't let applications write to just anywhere on an external SD card. Each application is given a folder on the SD card that they are allowed to write to. To get the path to that directory use the pathname function with argument CSEntryExternal. Something like:
string bkcsdb = pathname(CSEntryExternal) + "TCA";
dircreate(bkcsdb);
filecopy(pathname(CSEntry) + "TCA_10_Entrevista.csdb",bkcsdb);

Re: Accessing an external memory card

Posted: May 29th, 2019, 2:02 pm
by AriSilva
Thanks, Josh,
It worked!
Best
Ari

Re: Accessing an external memory card

Posted: February 27th, 2020, 6:23 am
by btri Arjun
Dear team,

I want to copy the data file to an external SD card. I have set the data file name as;

xfilenum = concat(edit("99",Distirct), edit("99",(Cluster_No) ));
My data is within “Csentry/Survey 2020/Data, H2540.Csdb (25 is district and 40 is cluster no)
Now we are using HUAWEY tablet model no BG2-U01. My external card name is “SD Card”. I have used the following function but not working. I think I wrote the wrong path. Can anybody help me?

Function backupSDcard()
string Backup = pathname(CSEntryExternal) + "SD Card";
dircreate(Backup);
if direxist(strip(Backup)) = 1 then
FileCopy(concat(strip(Data), "\?",strip(xfilenum), ".CSDB" ),strip(Backup) );
errmsg("Data Copying processs completed ");
endif
end;

Thank you.

Arjun

Re: Accessing an external memory card

Posted: February 27th, 2020, 9:34 am
by josh
Remove the "SD Card" from the backup path. The path returned by pathname(CSEntryExternal) will already include that. If you do add something to the end of pathname(CSENtryExternal) you need to add a trailing / character to ensure that filecopy knows you are trying to copy into a directory and not a single file.

If you use string variables you don't need to use strip. That is only if you are using an alpha dictionary variable with a fixed length. You can also use + instead of concat to make your code more readable.

The best way to debug this stuff is to use errmsg() to show the paths that you are creating so you can see what they are after all the concats.

Re: Accessing an external memory card

Posted: June 26th, 2020, 9:47 am
by martinjacobs
External Sd cards usually dont get read by the devices. I have faced the same problem many times.