I'm writing an application where there are a few hundred merchants, and each one has a logo. For the existing merchants, I've put their logos in Resources/images/merchants - then when I need to serve up the image, I use a URL and that is all working fine.
The problem is, now there are new merchants that get added via an update process. I've learned that Titanium.Filesystem.getResourcesDirectory() may not be writable, and the application should not attempt to write to it. This means, for new merchants, my best bet is to use getApplicationDataDirectory(), but doing this as is would leave my images in 2 different directories, which wouldn't be good.
Possible Solution: When the app first starts, transfer all the merchant logos from getResourcesDirectory() to somewhere in getApplicationDataDirectory()?
Ideally, I would like to ship the app with the images in a location that is writable so that they don't need to be moved. Does such a location exist? Has anyone else tackled this same problem and have an elegant solution?
Thanks in advance...
I am on the same path: a content distributed with the app that can be replaced. As you state, at first run you can copy the content to the applicationDataDirectory. And this is what I do. You can also download it to that directory without having to include into your distribution
The problem with copying the images from your resources folder to the ApplicationDataDirectory is that you then have duplicated the file space those images take up.
I would imagine you are adding the merchant information into a local database, with existing entries already being included and new ones being added.
I would consider adding a flag field to the merchant table which tells you where to find the image. This way in any loop you are running you can simply ask the recordset which of two location should you look and a simple if statement will resolve the problem.
This tiny change will more than be made up for in the extra file size needed to host a proportion of images twice, and would be better for your app users as well as your app takes up less space.
The flag field could be a simple integer; with 0 or 1 stored in it.
Think you can help? Login to answer this question!