finding files

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

finding files

Post by cwkalish » Fri Oct 28, 2011 8:03 pm

Hello,
I've installed an app on my Android device's internal storage. The app writes some files-- but I can't find the files on the device. Files are created in the documents folder; specialfolderpath("documents"). I can list them within the app, confirming they were created. But I can't find them using the device's file browser. (this is Froyo w/ a flytouch tablet).
Thanks.
_Chuck

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

Re: finding files

Post by BarrySumpter » Tue Nov 01, 2011 9:18 pm

I'm sure I've posted about this file path issue on Android before.
May have some luck viewing my posts.

But may have removed my posts do to drunken frustration with RunRev.

Been out of the LiveCode Android development study for a few weeks now.
Just visiting to see if I can get the scent back.
Nope. Not so far.
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.

cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

Re: finding files

Post by cwkalish » Thu Nov 03, 2011 10:44 pm

Hmm. After reading those older posts I get the impression that the documents folder might be inside a kind of zip archive, invisible to the rest of the Android OS. Could that be right?

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

Re: finding files

Post by BarrySumpter » Thu Nov 03, 2011 11:24 pm

It's a shame you have to get help from someone who is no longer developing with LiveCode.
I've moved over to Basic4Android. Heaps cheaper with better support and an lot more Android functionality.

This is a card I've extracted from one of my projects.
I got it from another member here.
Can't recall if I've moded the code to suite my purposes or not.

This card was Never designed for a user to see.
It was for diagnosis purposes only.

It should get you started.
With no guarantees that it will even work.

Android file locations are NOT windows and iOS locations.

The installation folder is protected at run time.
The documents folder is automatically prefixed with your
apps 'Identifier' field in Android settings in Standlone application setting.

whewh!

hth
Attachments
File Locations.zip
(3.17 KiB) Downloaded 459 times
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.

cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

Re: finding files

Post by cwkalish » Thu Nov 10, 2011 8:30 pm

I still haven't had any luck finding the "documents" fold in Android

Let me try another tack: How does one write to an SD card from a livecode app?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: finding files

Post by jacque » Sat Nov 12, 2011 3:11 am

The file folders in an Android app (and an iOS app too) are sandboxed and you can't see them or access them. If your device is rooted you might be able to spot them, but they are intentionally protected and hidden by the OS and for the most part you should only rely on access from within your app.

Some apps do create their own external folders for file storage though, which the user can see with a file manager. On my device, most seem to be in "/mnt/storage/" followed by a folder named for the app. I haven't tried it, but I don't see why it wouldn't work.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: finding files

Post by BarrySumpter » Sun Nov 13, 2011 1:56 am

Using the app i've uploaded,
you'll need to remove the files from the copy file page under standalone application settings
and on the FileLocations app
clear the file locations text box
and the File Contents text box
and the text box at the bottom before testing

you then test by targeting your physical device.

Once the app fires on your physical device
Press the show engine files button on the physical device

Code: Select all

...
set the defaultFolder to  specialfolderpath("engine")
...
put "DefaultFolder: " & return & the defaultFolder & return after fld "FileContents"  
...
under file location: you'll see the
/data/app/xxx.xxx.xxx-appName-x.apk/
This is a folder AND a reference to your installation application package
This exact folder in on the physical device and NOT on your SD micro card.
The xxx.xxx.xxx is the Identifier content under the Standalone Application settings under the Android page.
appName-x.apk
- appName is the Lable on the same Android page.
- x is sometime 1 and sometime 2. I'e never seen 3.

I use a free app from he market 'File Expert' to browse the folder
Using File Expert if you click on appName-x.apk it will try to install your app again.



Back to the test app
on the bottom half you'll see a selection drop down box
click the down arrow and select 'engine' or ' documents'
Selecting 'Engine' will show as above with all files and sub-folder, etc.

Code: Select all

set the defaultFolder to  specialfolderpath("engine")
As mentioned the specialfolderpath("engine") is protected and is NOT writable.

Selecting 'Documents'

Code: Select all

set the defaultFolder to  specialfolderpath("documents")
Gives me:
Default Folder:
/data/app/xxx.xxx.xxx-2.apk/webkit
also the path:
/data/data/xxx.xxx.xxx/files
is where the files you specified to include in your installation on the Standalone App Settings
on the Copy Files Page
This folder is NOT writable once your app has installed.
But the files are readable.
Although, I don't know if these file are readable by your app only.

My last research indicated that LiveCode was unable to install to the sd Card in any way.
A work around is to install the app then use the app to download writable data to a folder on the sd Card.

hth
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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: finding files

Post by jacque » Sun Nov 13, 2011 4:26 am

I bet your device is rooted. The data/app/ folder isn't visible on an unrooted device (like mine.)

The ability to install to the SD card was just added in the last developer release and it works really well. You'll see it in the next public release.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: finding files

Post by BarrySumpter » Sun Nov 13, 2011 9:29 am

yes, phone is rooted.

Promises, promises, promises.

Will RR be charging for that release as well?

LOL
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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: finding files

Post by jacque » Sun Nov 13, 2011 7:51 pm

No idea if they will charge, I'm not privy to how sales work. You could ask support.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: finding files

Post by BarrySumpter » Sun Nov 13, 2011 10:34 pm

jacque wrote:No idea if they will charge, I'm not privy to how sales work. You could ask support.
I've promised support I wouldn't contact them any more.

I'll just wait n see like always.
Basic4Android is keepin me busy.
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.

cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

Re: finding files

Post by cwkalish » Tue Nov 15, 2011 3:27 pm

Thanks. I think I'm getting the picture.

Are the sandboxed files created within the .apk file? If so, I should be able to copy the .apk, rename it as a .zip and then find the created files?

Barry's message suggests I can write a file to the SD card. Do I just specify a path like: "//SDcard/myfile" ?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: finding files

Post by mwieder » Tue Nov 15, 2011 6:37 pm

I posted this to the list the other day, but I think Jack Palevich's Terminal Emulator is the Best Android App Ever. If you know your way around a command line, this should solve all your "where's that file" issues. Oh - and it's free. As in beer.

http://www.androlib.com/android.applica ... -zxnC.aspx

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: finding files

Post by mwieder » Tue Nov 15, 2011 6:40 pm

Barry- nice to see you're still looking in on things here. I think Android support is about 40% there right now - not exactly ready for prime time. There's been quite a bit of discussion over the last couple of weeks about what's not there. Socket support is the big missing item for me at the moment, so I'm doing some dev work with Appcelerator Titanium. Basic4Android looks interesting, but the thought of having to use Basic gives me the willies.

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

Re: finding files

Post by BarrySumpter » Tue Nov 15, 2011 9:24 pm

Yeah, I missed VisualBasic after moving to REALbasic.
I missed REALbasic after moving to LiveCode.
I missed LiveCode after moving to Basic4Android.

Code: Select all


-- This was working for me before moving to Basic4Android
-- My coding is meant only for and is sufficient for me - not some non-existant party who will never review my code
-- this is just a snippit of a much larger app
-- please accept this as a place to start and not a solution

on mouseUp

  if label of button cmdOk  = "Save" then
      
      put the dgDataOfIndex [Field lblPreviousSelection] of group dgAudio  into theDataA
      
      put field lblWhichSound into tWhichSound
      put theDataA["Name"] into tName
      put theDataA["Path"] into tPath
      
      put "myAPP - preferences.txt" into theFileName
      
      set the itemDelimiter to space
      
      put GetAppFolder() into tAppPath -- this be where the installed files are for me installed app - n the Copy Files from Stadalone app Settings 
      put GetDocFolder() into tDocPath -- this be where me updated data and MyPreferences files be when I save data or save preferences
      
      Put tDocPath  & slash & "preferences" into theFolderAndFileName
      
      if there is a folder theFolderAndFileName then
         -- do nothing
      else
         create folder theFolderAndFileName
      end if
      
      Put theFolderAndFileName  & slash  & theFileName into theFolderAndFileName
      
      if there is NOT a file theFolderAndFileName then
         put "Sound" & tab & "Interval" & return & "Sound" & tab & "Finish" & return into theData
         put theData into url ("file:" & theFolderAndFileName)
      end if
      
      put url ("file:" & theFolderAndFileName) into theData
      
      put lineOffset(tWhichSound,theData) into tWhichLine
      
      put "Sound" & tab & tWhichSound & tab & tName &tab & tPath into linUpdateLine
      put linUpdateLine into line tWhichLine of theData
      
      put theData into url ("file:" & theFolderAndFileName)
      
      
      go to card iSettings
      send "openCard" to card iSettings
      
end if


Function GetAppFolder -- tAppPath
   
   -- SpecialFolderPath (Documents) folder DOES exist on environment win32
   --    But I DON'T want to use the documents path on environment win32
   -- 
   -- I want to use the applications subfolders Doco and Vids on Environment win32
   -- 
   -- SpecialFolderPath(Engine) DOES NOT exits on environment win32
   --   set the defaultFolder to specialFolderPath("engine")
   --   answer the result
   --         on win32 returns: can't open directory
   --
   -- SpecialFolderPath(Engine) is for Android and iOS
   --     the Android installer package saves READ ONLY in the Engine Folder
   --     you can include extra folders with the files contained within the folders 
   --     using Copy Files dialog in StandAlone settings
   
   
   -- get the file path for this stack
   
   -- the effective filename of this stack if the FULL FOLDERnFILENamePath
   put the effective filename of this stack into tPath   
   set the itemDelimiter to slash
   
   if the platform = "MacOS" and the environment = "standalone application" then
      -- if this is a standalone application running on a Mac, find the path to the .app file
      repeat until last item of tPath contains ".app"
         delete last item of tPath 
      end repeat
   end if
   
   
   if the platform = "win32" and the environment = "standalone application" then
      put the effective filename of this stack into tPath
      set the itemDelimiter to slash
   end if
   
   if the platform = "win32" and the environment = "development" then
      put the effective filename of this stack into tPath
      set the itemDelimiter to slash
   end if
   
   if the platform = "android" and the environment = "mobile" then
      set the defaultFolder to specialFolderPath("engine")
      put defaultFolder into tPath
      if character -1 in tPath is slash then delete character -1 of tPath
      Return tPath
   end if
   
   
   -- remove the last item to get the path to the containing folder
   delete last item of tPath
   
   Return tpath
   
end GetAppFolder


Function GetDocFolder
   
   
   -- get the file path for this stack
   put the effective filename of this stack into tPath
   set the itemDelimiter to slash
   
   if the platform = "MacOS" and the environment = "standalone application" then
      -- if this is a standalone application running on a Mac, find the path to the .app file
      repeat until last item of tPath contains ".app"
         delete last item of tPath
      end repeat
   end if
   
   
   if the platform = "win32" and the environment = "standalone application" then
      put the effective filename of this stack into tPath
      set the itemDelimiter to slash
   end if
   
   if the platform = "win32" and the environment = "development" then
      put the effective filename of this stack into tPath
      set the itemDelimiter to slash
   end if
   
   if the platform = "android" and the environment = "mobile" then
      set the defaultFolder to specialFolderPath("documents")
      put defaultFolder into tPath
      if character -1 in tPath is slash then delete character -1 of tPath
      Return tPath
   end if
   
   
   -- remove the last item to get the path to the containing folder
   delete last item of tPath
   
   Return tpath
   
end GetDocFolder

Last edited by BarrySumpter on Wed Nov 16, 2011 4:36 am, 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.

Post Reply