Accessing an external memory card

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Accessing an external memory card

Post 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
Best
Ari
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Accessing an external memory card

Post 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);
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: Accessing an external memory card

Post by AriSilva »

Thanks, Josh,
It worked!
Best
Ari
Best
Ari
btri Arjun
Posts: 37
Joined: August 17th, 2018, 6:09 am

Re: Accessing an external memory card

Post 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
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Accessing an external memory card

Post 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.
martinjacobs
Posts: 1
Joined: June 26th, 2020, 9:43 am

Re: Accessing an external memory card

Post by martinjacobs »

External Sd cards usually dont get read by the devices. I have faced the same problem many times.
Post Reply