Correct storage location for Data

You must Login before you can answer or comment on any questions.

path = {
    R : Titanium.Filesystem.resourcesDirectory,
    A : Titanium.Filesystem.applicationDirectory,
    T : Titanium.Filesystem.tempDirectory,
    AP : Titanium.Filesystem.applicationDataDirectory
};
Ti.App.path = path;
function fetchImage(url, town, position, callback) {
    var c = Titanium.Network.createHTTPClient();
 
    c.onload = function() {
        var path = 'scroll_images/' + town + "-photos-" + position + ".jpg";
 
        var imageDir = Ti.Filesystem.getFile(dir_path.AP, 'scroll_images');
        if (!imageDir.exists()) {
            // alert("Creating scroll image directory");
            imageDir.createDirectory();
        }
 
        var imageFile = Ti.Filesystem.getFile(dir_path.AP, path);
 
        // alert("path:"+path);
        // var f = Titanium.Filesystem.getFile(dir_path.AP,path);
        if (!imageFile.exists()) {
            // alert("data:"+this.responseData);
            imageFile.write(this.responseData);
        }
 
        // dispose of file handles
        imageFile = null;
        imageDir = null;
 
        callback("Image Loaded");
    };
    // open the client
    c.open('GET', url);
    // send the data
    c.send();
}
We have been using this code to load a downloaded image to the AP location, which we thought was correct, but Apple just rejected our App, and said it needs to go in:

  1. Data that can be downloaded again or regenerated should be stored in the <Application_Home>/Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.

How can we map to this directory?

We are also storing data inside the sqllite database, so not sure if this is also causing an issue for the iCloud backup, which is the main problem at the moment.

1 Answer

Accepted Answer

Ti.Filesystem.applicationDataDirectory+'../Library/Private%20Documents/';

Ti.Filesystem.applicationDataDirectory+'../Library/Caches/';

— answered 9 months ago by Stephen Feather
answer permalink
7 Comments
  • Additionally, you may need to set the remoteBackup flag on your files if on iOS:

    if (utils.isIOS){
        myFile.remoteBackup = false;
    }
    Note: Could also be per directory:
    if (utils.isIOS){
        myDir.remoteBackup = false;
    }

    — commented 9 months ago by Stephen Feather

  • For your database:

    var db = Ti.Database.install('/mydb.sqlite3','mydb.db');
        if (utils.isIOS){
            db.file.remoteBackup = false;
        }

    — commented 9 months ago by Stephen Feather

  • http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.Filesystem.File-property-remoteBackup

    — commented 9 months ago by Stephen Feather

  • Show 4 more comments

Your Answer

Think you can help? Login to answer this question!