0
votes

i'm working on a Sencha Touch 2 app for android and iOS. App will load images and videos on login time and i need to cache them in the app. I know it video cache will be huge load but please let me know, can we store image files in app local folder or some other implementation.

Thanx in advance.

1

1 Answers

0
votes

I am a developer with SIMpalm (http://www.simpalm.com), Yes you can store files in your device, you should use phonegap (http://docs.phonegap.com/en/3.0.0/cordova_file_file.md.html#File) File System for downloading.

It will download the files on Default Location.

You Should Move the file on your targeted location.

Example :

function getImageURI(imageURI) {

var gotFileEntry = function(fileEntry) {
    //  alert("got image file entry: " + fileEntry.fullPath);
    var gotFileSystem = function(fileSystem) {


        fileSystem.root.getDirectory("TestFolder", {
            create : true
        }, function(dataDir) {
            var FileNewName = "test.jpg" ; //you can rename the file
            // Move the file
            fileEntry.moveTo(dataDir, FileNewName, success1, fsFail);

        }, dirFail);

    };
    // get file system to copy or move image file to
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem,
    fsFail);
};
// resolve file system for image
window.resolveLocalFileSystemURI(imageURI, gotFileEntry, fsFail);

var success1= function(success){
    //Moving Success
    var newFilePath=success.fullPath;

//Here you can save new path of your downloaded file

};
// file system fail
var fsFail = function(error) {
    console.log("failed with error code: " + error.code);

};

var dirFail = function(error) {
    console.log("Directory error code: " + error.code);

};

}// End getImageURI