Page 1 of 1

file save and recall in Android

Posted: Sat Apr 13, 2013 5:21 pm
by user#606
I cobbled together a Contact Manager to get more business, running on PC, it also works as is on the Mac.
As an enhancement, I added a "Personal" section and it would be very handy to access this from my Galaxy Note 10.1 outside business hours.
Everything appears to work, except file handling, and this is no real surprise, because the PC/Mac code is not supported on the Android. So much for cross platform compatability.

Question:- So I dont have to support several versions of code, is there a way around this issue?
The file structure is the simple save and load of a table field.
To save is:-

Code: Select all

   put field "Table 1" into url MyFileName
--other code here--- 
put field "Table 1" into url MyFileName
To Recall is:-

Code: Select all

 answer file "Select a text file:" with type "Contact Manager|mge|"
---Other code here---
put url recalledfile into Field "TempTable1"
In addition, file paths for reference documents can be dragged & dropped to a field in the application. These paths are stored with the client record as simple text, never the file itself. At this point, there is an option to move the file to a central folder, or copy the file, to the central folder. The central folder will be on a NAS device.
Question:- How do you drag & drop across different screens in Android. The application is the size of the Note Screen.

The file paths for the save and recall of the client records, and program settings are contained in a text file where ever the application resides. So far that will be one on a PC and another on a Mac. So there will need to be one on the Galaxy Note.
Question:- can you put this in the same folder as the Android app?

I would think these are common problems with computer and tablet combinations, so should be of interest to many other newbies.

Re: file save and recall in Android

Posted: Sat Apr 13, 2013 8:09 pm
by jacque
PC/Mac code is not supported on the Android. So much for cross platform compatability.
The code is cross-platform, but Android is not. It's the OS you are up against and the same would be true on iOS. On mobile, you can't alter anything in the folder that the engine is in, you can only write to the designated user folders in your app's sandbox. Those are the specialFolderPaths listed in the dictionary, with the exception of the engine folder, which is disallowed. For permanent files that won't get deleted by the OS, use specialFolderPath("documents"). If you don't want to branch your code, you can use the same place to store user files on desktop machines too. Once you choose a writable folder, the "put url" syntax will work fine.
How do you drag & drop across different screens in Android.
I don't think you can. Mobile apps have only one window at a time. I know Android is experimenting with multiple windows on their latest OS but most people don't have that yet and LiveCode doesn't yet support it. You can use normal drag/drop code to drag stuff around inside the current window though.
can you put this in the same folder as the Android app?
Only if the file is included as part of the standalone build, and if so, it will be read-only. If it is a file you need to write to (i.e., user settings,) it needs to be created in (or copied to) one of the app sandbox folders before Android will let you write to it.

Re: file save and recall in Android

Posted: Mon Apr 15, 2013 9:51 am
by user#606
Thank you Jacque for the clear and helpful advice.