FOLDERnFILE script examples that work on Android?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Wed Aug 24, 2011 9:15 am

Can't seem to find where we've discussed this before.

I thought it was on this forum but may have been elsewhere...

Android Note:
An Android application is installed on the phone in the form of its zip package. This means that any assets that are included are not available as discrete files in the native filesystem. In order to manage this the engine essentially 'virtualizes' the asset files you include, allowing (read-only) manipulation with all the standard LiveCode file and folder handling syntax. To access the assets you have included within your application, use filenames relative to specialFolderPath ("engine").

For Android systems:
• engine - The (virtual) path to the engine and its assets.
• documents - The path to a folder that can be used for per-application data files.
• cache - The path to a folder that can be used for transient per-application data files.

Value:
The specialFolderPath function returns a folder name and location.

I'm trying to get organized with lots of .txt files.

defaultAppFOlder = c:\BarrysApp

I can write to BarrysCatagory folder (already created) and File:
BarrysCaragory\BarrysCatagory-2011-08-24 1840.txt

I name the file this way so I can move file anywhere without worrying about the folder name.

its the same as:

Code: Select all

....
    put MyDGColumnNames & CR & MyDGText into url "BarrysCaragory\BarrysCatagory-2011-08-24 1840.txt"
....

Working in Windows:

Code: Select all

....   
   Put the label of this stack into theFolderName
   Put theFolderName & "\" & theFolderName & " - " & theFileName into theFolderAndFileName
   put "file:" before theFolderAndFileName
   put MyDGColumnNames & CR & MyDGText into url theFolderAndFileName
....
I can't seem to recall why this won't work on Android.

Blast! Just had a flash something about special folder engine being executable/read only.
And we should use the documents folder on Android.
I'm sure that was on this forum but can't seem to find the thread.

if the environment is "mobile" then
If the platform is "android" then

put the platform into tPlat
switch tPlat
case "MacOS"
case "Win32"
## Desktop
start player "player
break
case "mobile"
## do your mobile stuff here
break
### etc...

Code: Select all


      if the ENVIRONMENT is "mobile" then   
             -- ENVIRONMENT  -  development, standalone application, helper application, browser, mobile

          If the PLATFORM is "android" then    --  PLATFORM  -  MacOS, Win32, android, etc.

               Put the label of this stack into theSubFolderName
               put SPECIALFOLDERPATH("documents") & "\" & theSubFolderName INTO theFolderName 

               if there is NOT a FOLDER theFolderName then 
                     CREATE FOLDER theFolderName
               end if
               
               Put theFolderName & "\" & theFolderSubName & " - " & theFileName INTO theFolderAndFileName
               put "file:" BEFORE theFolderAndFileName
               put MyDGColumnNames & CR & MyDGText into URL theFolderAndFileName
         end if
    end if

      if the ENVIRONMENT is "standalone application" or the ENVIRONMENT is "development" then   
             -- ENVIRONMENT  -  development, standalone application, helper application, browser, mobile

          If the PLATFORM is "win32" then    --  PLATFORM  -  MacOS, Win32, android, etc.
               Put the label of this stack into theFolderName
               Put theFolderName & "\" & theFolderName & " - " & theFileName into theFolderAndFileName
               put "file:" before theFolderANdFileName
               put MyDGColumnNames & CR & MyDGText into url theFolderANdFileName
         end if
end if
...

...
For some reason I don't think I need the environment qualifier here.
I think just the platform qualifier will do.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: FOLDERnFILE script examples that work on Android?

Post by Mark » Thu Aug 25, 2011 8:26 am

Hi Barry,

Your code doesn't make any sense. For example, the label of a stack has absolutely nothing in common with the location of the stack on disk.

The docs are pretty clear about accessing files: relative to the engine. That means, you get the path to the engine and go from there.

Code: Select all

put specialFolderPath("engine") into myPath
put myPath & "/barrysFolder" into myBarrysFolder
put myPath & "/barrysFolder/somefile.txt" into myFilePath
-- etc.
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Thu Aug 25, 2011 11:36 am

-
Last edited by BarrySumpter on Wed Apr 11, 2012 7:37 pm, edited 2 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: FOLDERnFILE script examples that work on Android?

Post by Mark » Thu Aug 25, 2011 11:51 am

Barry,

I didn't say your posts make no sense, I said your code doesn't make sense. I also posted a useful example.

Bye,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Thu Aug 25, 2011 12:02 pm

-
Last edited by BarrySumpter on Wed Apr 11, 2012 7:38 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: FOLDERnFILE script examples that work on Android?

Post by Klaus » Thu Aug 25, 2011 1:53 pm

BarrySumpter wrote:....
The sample code you posted won't actually work on Android
and should be removed to keep others from wasting their time trying to test it.
Thats just MY opinion...
This piece of code that Mark supplied
put specialFolderPath("engine") into myPath
put myPath & "/barrysFolder" into myBarrysFolder
put myPath & "/barrysFolder/somefile.txt" into myFilePath
-- etc.
is definitivley and officially correct and will work on ALL mobile platforms currently supported by LiveCode!


Best

Klaus

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Fri Aug 26, 2011 12:10 am

-
Last edited by BarrySumpter on Wed Apr 11, 2012 7:39 pm, edited 4 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: FOLDERnFILE script examples that work on Android?

Post by Mark » Fri Aug 26, 2011 12:15 am

Barry,

You're not supposed to create files in the engine folder. You're supposed to create files in the documents folder.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Fri Aug 26, 2011 12:37 am

-
Last edited by BarrySumpter on Wed Apr 11, 2012 7:39 pm, edited 3 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: FOLDERnFILE script examples that work on Android?

Post by Mark » Fri Aug 26, 2011 12:47 am

I'm glad you figured it all out by yourself, Barry. Good luck experimenting.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: FOLDERnFILE script examples that work on Android?

Post by Dixie » Fri Aug 26, 2011 1:06 am

Barry Sumpter wrote...
So neither the file MyFile.txt nor the folder barrysFolder can never exist under the engine specialFolder.
You are wrong... a text file and indeed a folder 'Barrys Folder' is able to exist in the 'engine' folder. These files are placed, by using the 'copy files' pane, in the 'engine' folder when the app is built, and you can just 'read' from the files in the 'engine' folder....I have attached a stack that you can run under the android 'plugin' and see for yourself...

You can create, delete read and write to and from files and folders in the 'documents' folder to your heart's content! Mark's lines of code are not trying to create any files or folders whatsoever in the 'engine' folder, rather just trying to show you how to get to these files and folders so that you can access them.

Now please, stop shouting at the very people who are trying to help you with your obvious struggle to grasp even these basic concepts... Both Mark and Klaus are well versed in liveCode, they have both probably forgotten more about it than you will ever know, they are giving their time freely to help people who come to the forum to understand various concepts and strategies, not like some to treat the forum as their personal blog, to enable them to develop their apps or applications..

Have some respect!
Attachments
AndTest.zip
(3.41 KiB) Downloaded 371 times
Last edited by Dixie on Fri Aug 26, 2011 1:32 am, edited 1 time in total.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Fri Aug 26, 2011 1:07 am

-
Last edited by BarrySumpter on Wed Apr 11, 2012 7:42 pm, edited 4 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Fri Aug 26, 2011 1:45 am

-
Last edited by BarrySumpter on Wed Apr 11, 2012 7:43 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: FOLDERnFILE script examples that work on Android?

Post by BarrySumpter » Fri Aug 26, 2011 2:45 am

-
Last edited by BarrySumpter on Wed Apr 11, 2012 7:43 pm, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

jharris
Posts: 84
Joined: Wed Jan 26, 2011 3:28 am
Location: Arkansas - USA

Re: FOLDERnFILE script examples that work on Android?

Post by jharris » Fri Aug 26, 2011 3:12 pm

Just want to say thanks to everyone.

I have been wanting to make a little password database app for my Atrix using sqlite. I had toyed with it a little, but I couldn't figure out how to create my database file on the device.
After following this topic and filtering through Barry's nonsense I was able to write my little app in just 3 hours.

(I am sure this post adds no content, but Thanks to all.)

Regards,
jharris
Operating System: macOS Monterey Version 12.5
LiveCode Version: 9.6.8

Post Reply

Return to “Android Deployment”