Files and Folders

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm

Files and Folders

Post by Gene » Mon Jun 25, 2012 7:07 pm

I have a question that is probably going to be trivial when answered, but it has me stumped. I've found lots of information, but have unable to put it together to solve my problem.'

The bottom line is that I want to write a text file to the Android phone and the retrieve it with windows explorer via usb, or any of the other bluetooth, wifi, etc. connectivity.

For example, I can read and write my file to the specialfolderpath("documents"), but I can't find the folder, much less the text file using Windows Explorer with the Android linked via usb.

On the other hand, I can easily read the folders and files on the sd card with Windows Explorer, but I can't find the right syntax to write a file to the sd card from the Android! I have tried every way I can think of the set the default folder to the sd card root, or a folder within, without success. It would seem that if I could do this, then I could write to a folder on the sd card and retrieve the file with Windows. Or, if I could find the specialfolders ("cache" or "documents") with Windows, then I could retrieve it that way.

So, can anyone spell it out for me how I go about putting information gathered with my app to somewhere on the Android so that it can be accessed for use by my desktop computer.?

A solution would be much appreciated.

Thanks, Gene

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Files and Folders

Post by sturgis » Tue Jun 26, 2012 1:37 am

You might look at this post http://forums.runrev.com/viewtopic.php? ... ard#p52707
and as well, this stack http://dl.dropbox.com/u/11957935/filebrowser.livecode should let you click around through your file system (starting at specialfolderpath("engine") which due to the sandbox is basically /)
Can't interact with the files, but clicking the folders in the left pane will let you look around the file system.

You'll also need to make sure the "write external storage" is checked in the android standalone settings. there is probably an sdcard folder as well as a mnt/sdcard folder (as indicated in the posts linked above) If both exist they should be one and the same. (sdcard as a symboilic link to /mnt/sdcard)

Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm

Re: Files and Folders - PROBLEM SOLVED

Post by Gene » Tue Jun 26, 2012 4:58 pm

sturgis wrote:You might look at this post http://forums.runrev.com/viewtopic.php? ... ard#p52707
and as well, this stack http://dl.dropbox.com/u/11957935/filebrowser.livecode should let you click around through your file system (starting at specialfolderpath("engine") which due to the sandbox is basically /)
Can't interact with the files, but clicking the folders in the left pane will let you look around the file system.

You'll also need to make sure the "write external storage" is checked in the android standalone settings. there is probably an sdcard folder as well as a mnt/sdcard folder (as indicated in the posts linked above) If both exist they should be one and the same. (sdcard as a symboilic link to /mnt/sdcard)
sturgis - thank you for responding. I was beginning to think I was going to be stumped on this. Actually, the answer hit me after I decided to give it a rest and head for the grocery store. Isn't that the way it always happens?

It's so elementary, I kicked myself. The reason I couldn't find the right syntax to read the contents of the sdcard was that I was loading the app on my device using the usb connection. Fine - except that while the device is connected, the sdcard is disabled - hence, trying to read the contents was obviously futile with the usb connection still active.

When I loaded the app on the device, then unplugged the usb, and waited for the status bar notification to indicate, "preparing internal storage," then I was able use the app to work to the sdcard any way I wanted. The ultimate goal was to proceed to create a directory, and write a text file to it. This, of course, fell into place once I verified the syntax and ability to at least see the sdcard from the app.

Also, you were right, I didn't have the standalone option ticked for writing to external storage. I don't think that would affect the ability to read the external storage, but I think it would have given me additional fits when I went on to trying to create my text file. Fortunately, you stopped the fits before they got started with your advice to look at the external storage option.

The file explorer link you sent is interesting, and I intent to explore the code for whatever I can learn from it. I also looked at the link you provided to a previsous posting (I don't know how I missed it), which brought up basically the same question. However, the thread seemed to trail off without resolution. Even though it's an old link, I'm tempted to reply to it anyway with what I learned.

It's all good now, and I really appreciate the tips.

- Gene

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Files and Folders

Post by sturgis » Tue Jun 26, 2012 5:14 pm

Glad you got it figured out. That link I sent was mostly just showing where the sdcard folder should show up.


As for the file explorer, theres almost nothing to it (shoved together as quick as I could) so not sure you'll get much otu of it. Mostly I just use it to poke around the filesystem and see whats what. (and hoped it might help you locate the sdcard folder)


Also glad to know the sdcard won't show when usb is plugged in. Thats yet another thing I didn't know!

Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm

Re: Files and Folders

Post by Gene » Tue Jun 26, 2012 5:22 pm

When I bleed off some of my eagerness to press forward with the app, I'm going to try this whole exercise using the simulator and see what that looks like. I usually don't use the simulator because it is so slow to load, and I get more comfort out of testing on a physical device.

One last thing - I lied about the grocery store. I went to the pub. I have logged it as a two beer problem.
Last edited by Gene on Wed Jun 27, 2012 1:40 am, edited 1 time in total.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Files and Folders

Post by sturgis » Tue Jun 26, 2012 5:25 pm

a 2 beer problem isn't bad at all. If it turns into a vodka problem let me know.

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Re: Files and Folders

Post by pkmittal » Mon Jul 02, 2012 8:57 am

Hi, I downloaded the stack.. but when I open this stack in Livecode 5.0.2 then it does not open. and says that it is not an valid stack.

I would be very much interested in viewing this stack code as it would help to understand the files and folder system.. please provide me the version which i can use on 5.0.2

thanks
pradeep

sturgis wrote:You might look at this post http://forums.runrev.com/viewtopic.php? ... ard#p52707
and as well, this stack http://dl.dropbox.com/u/11957935/filebrowser.livecode should let you click around through your file system (starting at specialfolderpath("engine") which due to the sandbox is basically /)
Can't interact with the files, but clicking the folders in the left pane will let you look around the file system.

You'll also need to make sure the "write external storage" is checked in the android standalone settings. there is probably an sdcard folder as well as a mnt/sdcard folder (as indicated in the posts linked above) If both exist they should be one and the same. (sdcard as a symboilic link to /mnt/sdcard)

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Files and Folders

Post by sturgis » Mon Jul 02, 2012 1:24 pm

Try it now, its saved as a legacy stack, so re-download and give it a shot. Worst case i'll post the code. (its ultra simple would need lots of fleshing out to be a "real" file browser.)

In fact, heres the script. (set up a card with 2 scrolling list fields)

In the card script put this:

Code: Select all

on opencard
   set the width of field 1 to the width of this card / 2 --these lines just set things to use the whole screen
   set the width of field 2 to the width of field 1 --no rotation code, just bare minimum
   set the height of field 1 to the height of this card
   set the height of field 2 to the height of this card
   set the topleft of field 1 to the topleft of this card
   set the topright of field 2 to the topright of this card
   fillfilesfolders --this fills the 2 fields with files and folders based on default folder. 
end opencard
command fillfilesfolders --see above. 
   put the folders into field 1
   put the files into field 2
end fillfilesfolders
In the field that will contain the folders (field 1) put this script:

Code: Select all

on mouseup
   set the defaultfolder to the defaultfolder & "/" & the clicktext --changes the default folder based on the clicktext from field 1
   fillfilesfolders --refresh the fields. 
end mouseup
pkmittal wrote:Hi, I downloaded the stack.. but when I open this stack in Livecode 5.0.2 then it does not open. and says that it is not an valid stack.

I would be very much interested in viewing this stack code as it would help to understand the files and folder system.. please provide me the version which i can use on 5.0.2

thanks
pradeep

sturgis wrote:You might look at this post http://forums.runrev.com/viewtopic.php? ... ard#p52707
and as well, this stack http://dl.dropbox.com/u/11957935/filebrowser.livecode should let you click around through your file system (starting at specialfolderpath("engine") which due to the sandbox is basically /)
Can't interact with the files, but clicking the folders in the left pane will let you look around the file system.

You'll also need to make sure the "write external storage" is checked in the android standalone settings. there is probably an sdcard folder as well as a mnt/sdcard folder (as indicated in the posts linked above) If both exist they should be one and the same. (sdcard as a symboilic link to /mnt/sdcard)

Post Reply