2017년 7월 9일 일요일

Storing files to subfolder


i did search the forum but couldnt finde the solution although the topic did get discussed quite some times. 
So i ask for specific code for my app to get it working. Ty for that. 

The problem: 

As u can see on the attachment iam saving some values ( Questions/ text ) into a csv file. I was wondering if i can save the file
onto the sdcard into a folder which will be created by the app. From my research /foldername/filename ( wich is set by a textbox entry) 
should do it. ( but it doesnt :/ ). Is this function supported by AI2 ? 

Also the user should be able to send away the file via email.

The file shall be read and displayed on another screen in label -box in csv format again .

The Errors i get are:
1. file could not be saved into the set directory
2. file could not be found in the set directory

So i assume that i only got the path wrong. Right?

Also does any1 know if it is necessary to add a .csv to the file to make it usable with e.g. excel ? I didnt work for me without it.


--
see the documentation http://ai2.appinventor.mit.edu/reference/components/storage.html#File and use a relative path!



SaveFile(text text, text fileName)
Saves text to a file. If the filename begins with a slash (/) the file is written to the sdcard (for example, writing to /myFile.txt will write the file to /sdcard/myFile.txt). If the filename does not start with a slash, it will be written in the program's private data directory where it will not be accessible to other programs on the phone. There is a special exception for the AI Companion where these files are written to /sdcard/AppInventor/data to facilitate debugging. Note that this block will overwrite a file if it already exists. If you want to add content to a file use the append block.

Also the user should be able to send away the file via email.

Different eMail solutions for App Inventor

--
Hi ty for the replay.

I read this manytimes, but what about folders? They dont mention this at all. I only saw some post at the forums where they were talking about folders like this /sdcard/folder1/file1

and i dont rly get the diffrence between /sdcard/filename and file:///mnt/sdcard/.
Vreden

-- 
  /foldername/filename.csv 
this is a relative path

  file:///mnt/sdcard/foldername/filename.csv
this is a full path

the file component only is able to understand relative paths...
hope that helps

-- 
Yep, thanks that was clear :)

think i can work with this.

-- 
you should find that information in the documentation... usually the relative path should work

-- 

댓글 없음:

댓글 쓰기