collectordave

unread,
Jun 9, 2016, 3:43:05 AM6/9/16
to MIT App Inventor Forum
Simply trying to read a csv file on the SD card inserted into my device.

Tried the suggestions on the forum inserting / before the filename etc does not work.


The file is in the root folder of the SD card.


Can the file component read files from the SD card?

Any help appreciated.

regards

Ghica

unread,
Jun 9, 2016, 4:45:57 AM6/9/16
to MIT App Inventor Forum
Try Taifun's example:
http://puravidaapps.com/read.php
Cheers, Ghica.

collectordave

unread,
Jun 9, 2016, 7:31:07 AM6/9/16
to MIT App Inventor Forum
Thanks for the reply

Taifuns example seems to not show how to read a file from the SD card

Still looking
cd

collectordave

unread,
Jun 9, 2016, 7:52:30 AM6/9/16
to MIT App Inventor Forum
After numerous searches etc it appears that ai2 cannot read a file from an inserted sd card. It appears to be a problem for all Android devices.

Is this true? If so it is one big drawback to using Android.

My tablet has to import all data inserted on the SD card and cannot read it directly seems really odd for an operating system to not be able to read inserted storage media.

collectordave

unread,
Jun 9, 2016, 8:08:15 AM6/9/16
to MIT App Inventor Forum
Just noticed as well a lot of other posts on the forum regarding reading a file from an SD card have been closed. Why?

None of them have been answered successfully. Even when Prefix the filename with / to read from a specific file on the SD card. Is quoted as it does not seem to work at all.

Is there a way round this or is it something ai2 is lacking i.e. not able to read an external SD card.

Taifun

unread,
Jun 9, 2016, 10:25:42 AM6/9/16
to MIT App Inventor Forum
the file component can't read from the external sd card

you could use my file extension https://puravidaapps.com/file.php to copy the file first to the internal sdcard and then use the file component to read from there. 

The file component is very easy to use, see also the the documentation how to use it.

The App Inventor Extensions are currently in testing. See the announcement for more information and read the App Inventor Extensions document about how to use an App Inventor Extension.

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

collectordave

unread,
Jun 10, 2016, 11:29:31 PM6/10/16
to MIT App Inventor Forum
Ok

So the file component cannot read from an external SD card.

Connected by USB and copied files to a folder on the device. The file component can then read the CSV file OK.

Images cannot be accessed in the same folder to just simply display in an image component.

Tried another way round using the image picker component. The idea being if I can display the image the use the filename as a key to get the data from a list.

This appears to be limited to the gallery and will not navigate to another folder.

Are these restrictions general Android restrictions or are they restrictions placed on the programme by AI2?

TheJupiter732

unread,
Jun 10, 2016, 11:34:21 PM6/10/16
to MIT App Inventor Forum
You should be able to access sdcard files.
I had lots of tries to access it on different devices.

/sdcard/folder
/root/sdcard/folder
/root/dev1/sdcard/folder
/dev1/sdcard

etc. etc. etc.

I couldnt find out a pattern.

I cant tell if there are restrictions, but maybe you can solve your problem with sdcard now,

TheJupiter732

unread,
Jun 10, 2016, 11:40:41 PM6/10/16
to MIT App Inventor Forum
Oh, sorry. I had that problem with the source for music playing in the play component.

I cant tell if you cant access sdcard files with the files component.
Would be illogical tho.

collectordave

unread,
Jun 10, 2016, 11:59:14 PM6/10/16
to MIT App Inventor Forum
The problem seems to one of consistency between the components.

I can access the CSV file by creating a folder on the device, which appears to have an internal SD card, then copying the files to that folder. Once created the csv file can be accessed but not the images which cannot be displayed in the image component.

When I use the image picker component I appear to be limited to the gallery on the phone and cannot navigate to my newly created folder to display my images. I have seen one question on the forum where it says the image picker displays all folders with images on the device which appears to be untrue in my case. Again no consistency in operation.

I feel that some way of allowing ai2 to create a folder easily for the apps use would be fine if external data could then be easily imported to that folder. Of course once created using absolute paths to read files and display images or play sounds etc should, I feel be available.


collectordave

unread,
Jun 11, 2016, 4:21:15 AM6/11/16
to MIT App Inventor Forum
This gets a little weirder.

When I use "/mnt/sdcard2/Images/0002.jpg" as the filename to load an image into the image component it works, the image from the External SD card is loaded into the image component and is shown.

However when I use the file component with "/mnt/sdcard2/Test.csv" the file is not loaded!

I have, just in case changed things around a little to "/mnt/sdcard2/Images/Test.csv" as I know the folder is accessible because the image is loaded, but I am told the file does not exist!


Taifun

unread,
Jun 11, 2016, 4:04:46 PM6/11/16
to MIT App Inventor Forum
as already said earlier, the file component cant access external sdcards, you might want to read my previous answer for a workaround...
Reply all
Reply to author
Forward
0 new messages