Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Copy files to Documents directory on first run

In my app I added some code that will move a few folders from a source folder under images into the Documents folder when the app first runs.

The move works perfectly in the simulator, but does not work on an iPhone (running iOS 4.0.1).

Is this:

  • a bug?
  • a permissions loophole that the simulator is not supposed to allow?
  • altogether the wrong way to go about adding initial data to the Documents folder in the first place?
— asked July 26th 2010 by Ted Haeger
  • documents
  • file
  • ti.filesystem.file
  • titanium.filesystem.file

3 Answers

  • I'll answer my own question…

    Apparently, it is a permissions loophole. The Simulator allows something that the phone does not.

    This article gave me a different way to go about accomplishing my objective:

    — answered July 28th 2010 by Ted Haeger
  • Since this post is no longer available in the web, I hunted it down at internet archive. Here is the bit that was helpful to me:

    if (Ti.App.Properties.getInt("installComplete") == null) {
         var imgOriginal = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + "/image.jpg");
         var imgInstall = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + "/image.jpg");
         var dataOrig = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + "/data.txt");
         var dataInstall = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + "/data.txt");
         var dataContent = dataOrig.read();
         Ti.App.Properties.setInt("installComplete", 1);
    — answered February 22nd 2012 by Brian Wilhelm
  • hi, your question is very old may be you got answer till now but i wanna answer. there is a catch that you cannot move any file from resource directory , as move means you are removing it from resource directory, and titanium does not allow write permissions , so what you can do is read that whole file or directory and write it in the application data directory

    — answered April 18th 2013 by Ishan Singh
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.