Android Filing System using LC9
Dave Kilroy
dave at applicationinsight.com
Mon Oct 30 08:33:26 EDT 2017
Hi Peter
I’ve just done a new test build for my Galaxy S7Android (running Android 7) using LC 9.0.0 (dp10) and I’m able to transfer files from ‘engine’ to ‘documents’ and to write to ‘documents’.
I’ve never had to manually add “Android” and have found specialFolderPath() to be solid for my on Android - but there again I’m not trying to access data the app stores on the device by any method other than using the app itself...
This is what I’m currently using to set up local files (it’s a bit sloppy and could do with updating - especially the test for whether or not to copy all the files over) - but it works:
on setupLocalFiles
if isMobile() then
put the defaultfolder into tDefault
put specialFolderPath("engine") & "/ehrdata/" into tFolder
set the defaultfolder to tFolder
put the files into tFiles
repeat with i = 1 to the number of lines in tFiles
if char 1 of line i of tFiles = "." then delete line i of tFiles
end repeat
set the defaultfolder to tDefault
put specialFolderPath("engine") & "/ehrdata/" into tSourceFolder
put specialFolderPath("documents") & "/ehrdata/" into tTargetFolder
if there is not a folder tTargetFolder then create folder tTargetFolder
put (the ehr["templateId"] of the current stack) & "_exampledatareduced.json" into tCheckFile
replace space with "_" in tCheckFile
put files(tSourceFolder) into tFiles
if there is not a file (tTargetFolder & tCheckFile) then
repeat for each line tFile in tFiles
if char 1 of tFile = "." then next repeat
put tSourceFolder & tFile into tSourceFile
put tTargetFolder & tFile into tTargetFile
put URL("binfile:" & tSourceFile) into URL("binfile:" & tTargetFile)
end repeat
end if
end if
end setupLocalFiles
And this is and example of how I write “on the fly” to ‘documents - again it’s a bit convoluted (it uses encryption) as it’s specific to my needs - but it works:
on savePrefs
put the uPrefs of stack "Diadem" into tPrefs
put doEncryptAnd64(tPrefs) into t64
if word 1 of t64 <> "Bad" then
if isMobile() then put "documents" into tSpecialFolder
else put "resources" into tSpecialFolder
put specialFolderPath(tSpecialFolder) & "/prefs/"into tPath
if there is not a folder tPath then create folder tPath
put tPath & "prefs.txt" into tFile
put t64 into URL("binfile:" & tFile)
else
answer "Error:" && t64
exit to top
end if
end savePrefs
Kind regards
Dave
More information about the use-livecode
mailing list