Very large sqlite database copy - iphone

I see from this question ( SQLite Database Copy ) that one must copy the sqlite database from the bundle to the working directory on installation for it to not be read-only. But what if the database is huge? I don't want it to take up twice the space it should. Is there a way to delete the original from the bundle? Any other workaround to avoid wasting so much space with a large db in the bundle that is never used after installation?
Thanks!

How big is very large?
And you can't modify the bundle in any way whatsoever, including deleting / renaming / modifying files etc.
If you want to modify your db you will have to copy it out of the bundle.
However, Apple have got a solution for low space. If you can recreate the data, you should copy your db into the caches folder, not the documents folder. That way it won't get pushed into the cloud and if the device is low on space, it can be cleaned out automagically by ios.

There is no way to delete a file from the application bundle resources directory (read only).
If your DB is too large to be copied I suggest to download the database when the application start for the first time.

Another approach is to create a database programmatically using sql statements upon installation instead of embedding a sqlite database in a bundle.

Related

saving "mocked" mongodb collections in version control

I am developing on two machines (switching PC and laptop during the week) and try to find the best way to synchronize a limited amount of dummy data in the mongodbs running on each machine.
My first quick & dirty idea was to track the relevant files, containing the collection data inside of a db folder (inside my project folder) by Git.
I saw for example files named e.g. collection-0-1858325258041703863.wt which seem to contain what i am after.
However i am not sure about the rest e.g. index-1-1858325258041703863.wt files, sizestorer.wt, WiredTiger.wt etc..
Which are the files i have to track and which are the ones i can ignore?
I am aware that i could create a mock server with only json files and that saving binaries in VC is bad, but still i am curious if this way is possible (Mainly because working with MongoCompass is way easier than editing json files)

iPhone File System

The MyProjectName.app should be in the iPhone App structure directory as read-only, but in the project I have to join Test.sqlite and compile it, then I see the Test.sqlite in the MyProjectName.app.
I posted the project to the physical machine and inserted some data without issues. Is this the right way?
When I add the Test.sqlite and data on the iphone simulator, the Test.sqlite didn't appear to have any data. I have tried to copy the Test.sqlite to Documents. And then when I did it again, the data was displayed in the Documents's Test.sqlite. Do I need Test.sqlite to be copied to the Documents? thank you
The resources which are modified at runtime should be part of Documents directory. iPhone application creates a sandbox environment which is signed. If you try to modify any of the bundle resource, it will not allow. It works fine with simulator but not with device.
So, whatever resources are modified should be copied from bundle to documents directory.
Also, when upgrade is available, bundle is replaced with new version. However documents directory does not change. It remains same. If you want to carry any change with upgrade, you can modify data accordingly.
Hope it helps.
Check the Test.sqlite file is it read only or read/write.Change it into read/write.And if there is any lock for the project just uncheck it.

How to make Custom Application to persist reboot of WinCE 6.0 OS?

I am looking for a solution on how to setup the Windows CE 6.0 design image to integrate my custom application.
I want after building the image and starting it on the target machine to be able
to access my application from the \Hard Disk\Program Files\CustomApp folder.
In addition I require the application to be persistent. It must not be lost after reboot.
I am aware of copying the application to the Hard Disk out of the NK.BIN but if is possible I want a solution like adding dlls or other files to Windows folder.
I am usign an SQL CE database along with the application so I want the data to be persistent too.
Thanks in advance.
If the \Hard Disk folder contents are not persistent (and I assume they aren't since you're asking this questions), then getting the app to "persist" can be done only as a slight-of-hand trick, just like the contents of the Windows Folder. At boot, the OS will get expanded into RAM, and if you've included your app in that OS, it will get extracted too.
First, you must include your app files (exe, dlls, all dependencies, etc) into the OS image by adding them to a BIB file.
Next, you must understand that all files get extracted to the \Windows folder. There are no exceptions. If you want it in a different folder, you must use a DAT file to tell the OS where to put it one the OS has been extracted. Be aware that the DAT file does a copy, not a move, so if you want it elsewhere, you'll have two copies of the app on the device. A typical solution is to use the DAT file to place a shortcut, not a full copy.
The last part of your question is the hard, or maybe impossible, part. Your database is not going to persist. You could include a copy in the OS, but every time you hard reset, a new copy of the database as it was when the OS was built will get copied out. No new data will survive.
To get that to work, you need a persistent file store on the device. If you're the OEM, you might be able to implement one with any remaining on-board storage (where the OS image file resides) or with separate mounted USB/CF/SD/HDD media. How you do this is highly hardware and BSP dependent, plus it's way more complex than can be described here on SO.Without knowing anything about the target device, it difficult to even give you any pointer on where to begin. Here's a very generic starting point for Flash storage.

iphone - where should I store image files if I don't care about its persistence?

I know normally I have two choices of places: Temporary folder or Cache folder.
But can anyone tell me the exact differences?
My app will download quite many images upon users' requests. Of course, no one need them on the disk of iphone permanently. But I still need to cache them in the case users will go back to see them in relatively short time period.
Temporary folder can be one place to go, as I understand it will be cleared by the system. But when will it be cleared?
For cache folder, will cache folder be cleared regularly as well? If the cache folder will not be cleared, and I write the images to Cache folder, that will occupy too much spaces in a longer term, and it is not good for the users of course.
So, can someone give me some hints and tell me the exact diff between these two folders?
Thanks
I would go with the Caches folder— look in NSPathUtilities.h for the relevant methods to get at that one. The Caches folder won't be backed up, but it won't necessarily be emptied either, and neither will the temp folder. /tmp would normally be cleared upon reboot (well, potentially), but on the iPhone that's not something that will happen commonly.
The best approach would be to put data into the Caches folder using some date-based scheme, so that you can clear its contents yourself when you deem it useful to do so. You could use the file's creation or modification date to inform this decision, and simply scan at each launch (or each enter-foreground event) to determine which items are old enough that they should be removed.

iPhone Documents directory and UIFileSharingEnabled, hiding certain documents

I want the user to be able to access the files in the documents directory but am using core data and dont want the user to be able to access the store (the sqllite db), can i hide it from the user while still allowing file sharing, or can i put it in another directory where it will still get backed up?
The answer given by FrenchKiss Dev is not correct. The user will still be able to see the ".data" directory in iTunes and save that locally with all the files inside it.
Instead, store private documents in Library/Preferences
According to Apple:
In addition to the directories documented previously, the entire
/Library directory has always been preserved during
updates and backups, except for /Library/Caches.
Because of this, applications can create their own directories in
/Library/ and those directories will be preserved in
backups and across updates. To minimize the risk of name collisions,
we recommend that you name this directory carefully. For example, a
directory named Private Documents would be a good choice. You should
store any files you don't want to share to Library/Preferences.
In the documents directory, create a subdirectory which name starts with a dot. For example:
.data
EDIT: Please stop downgrading this answer !
This answer was correct at the time (remember that it was before the iPad was actually available! And there was a lot of confusion on the matter, we were still hoping for the iPad to appear in the shared devices in the Finder...).
Today (April 2012) it is still working on the Mac but not on Windows (starting a directory name with a dot means nothing in Windows).
Anyway, this Shared Document feature is a mess. Later they fixed it by saying that "Private Documents" should be stored in the Library Folder not in the Documents folder. But remember that developers were already using the Document folder before the iPad came.
Don't blame me for Apple mistakes.
Stack Overflow should have a way to mark an answer as obsolete.
API changes, get fixed, and it renders answers obsolete.