I'm attempting to push an up-to-date version of my sqlite db to my tool and to date haven't determined a method to get it done apart from renaming it every time (painful). The stale (cached?) copy remains permanently around the device.

I learn how to have an up-to-date version in to the simulator by clearing the /programs folder, but this doesn't appear to modify the physical device.

Suggestions?

When the database file is a component of the application bundle whenever you update the application you'll update the database.

When the database isn't area of the application bundle but is within a read-write space (such as the documents directory) you will need to implement your personal strategy.

I incorporate a schema_version table my database:

create table schema_version (
  version integer not null
);

after which on application launch, I look into the current version then look during my application directory for any update-schema-[N+1].sql file to use being an update. Therefore if my schema version is 4, I'll look for update-schema-5.sql etc. (and that i continue doing this when needed until I exhaust update-schema-N.sql files to use.)

Be advised the write performance of sqlite around the apple iphone is not everything great. If you want to update 200K database rows, you will probably need to determine a way of keeping the consumer amused even though it is happening.

My application utilizes a hybrid approach where we've most (60 Megabytes) in our data inside a read only database along with a more compact read-write database for user led and cached content.

You can write an OS X command line application to 'diff' that old and also the new db. Then send the unit a JSON object (or XML) of all of the adds, removes, and updates and apply these to the present store.

You might copy your store towards the Documents folder around the first run from the application and browse it after that. The Documents folder has read/write/remove access and so i think you can just sub the brand new one out of. You will get that path like so.

NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains(
    		NSDocumentDirectory,
    		NSUserDomainMask,
    		YES);

NSString *docDir = [arrayPaths objectAtIndex:0];