I know that I can show the location of the App Data Dir by using:
Ti.Filesystem.applicationDataDirectory
But what if I want to have my app prepacked with some documents in this directory? Is there a place I can put them so they're included at build time? I don't want to use the Resources directory because I want them immediately available for the user to transfer from iTunes.
Is this possible?
Incidentally, a workaround I thought of is putting the files in the Resources folder and then the first time the app launches I could copy them from the Resources dir to the Application Data dir and then delete them from the Resources dir.
3 Answers
Correct. What you want to do is have your program look in the app data directory and if the files are not there yet, copy from the resources folder. Note that you must copy the file instead of attempt to move or rename it, because the resources folder is read-only. Thus any attempt to move to another path will fail.
Thanks, Doug. I can do that, but I'm afraid for my purposes the files will be too large (100MB?) and so this would basically double the size of my app. Doable, but not ideal.
The other option I thought of is creating a network connection so I could allow the user to browse to a URL on the local network to download the files. I've been looking at the Sockets and Bonjour examples, but haven't figured out how to force the download of a file on the local web server.
Any advice for that?
Eugene, I guess you will have to make the decision decision on the paradigm of essentially doubling the app space, or requiring a network connection to download on first use. However, if the user connection is 3G instead of WiFi, doing a 100MB download is not as user friendly as consuming another 100MB of storage IMHO.
If you do want to download, look at this kitchen sink example. It was recently enhanced for iOS to download directly into a file object. That is not yet available on the Android SDK, and if the 100MB of documents includes any "large" ones (intentionally vague) you may have trouble doing the download on Android.
Your Answer
Think you can help? Login to answer this question!