On 23 Oct 2012, at 10:35pm, Igor Korot <ikoro...@gmail.com> wrote: > On Tue, Oct 23, 2012 at 2:26 PM, Doug Currie <doug.cur...@gmail.com> wrote: >> >> On Oct 23, 2012, at 4:58 PM, Igor Korot <ikoro...@gmail.com> wrote: >> >>> 1. I know on Mac I need to build an application bundle. Where do I >>> store the .db file relative to the bundle? >>> Inside it? Home directory? Somewhere on the hard drive? What is the >>> usual place for it? >> >> If the database is read-only, you can sore it inside the bundle. > > Nope. There will be new records insertion/old record update/delete. > >> If it is application configuration, you should store it in the application's >> directory in the user's ~/Library/Application Support/<application name> > > Nope. It is for an application data. > >> If the database is a document, you should store it wherever the use directs >> via a file dialog. > > So then user home directory (~) should be fine, right?
No. Never put anything in the home directory. That's just for other things Apple has already put in there. Most user's don't realise they have a home directory and will arbitrarily delete things they find there: "I don't know what this is for and I don't care about it.". If your user considers these SQLite databases to be their own documents (i.e. like a word processor saves text documents, your application saves SQLite databases) then you must use Apple's standard 'Save' and 'Open' APIs to allow the user to decide where the files go. This gives the user all the facilities they're used to, like drag-and-drop and automatically picking the most recently used directory. Most users will chose to keep their documents on the desktop or in their own Documents folder, but will regard any application which doesn't give them the ability to choose as weird and broken and will not use it. If one of these files disappears between runs of your program then the application just considers that saved document to have been deleted. If your SQLite database is used to support the inner workings of your application that the user knows nothing about and never has to manipulate themself (e.g. a web browser might keep an internal database of DNS addresses) then there are two possibilities. If you only need one of these files, no matter which user is using your app, then it belongs in "/Library/Application Support/<application name>". If each user needs their own file then it belongs in "~/Library/Application Support/<application name>" as Doug wrote. Apple provides an API which will provide the correct pathname for you, as Petite wrote. You would never have to know the above path yourself unless you're writing in a language which cannot access Apple's standard API. If one of these documents disappears between runs of your program then your application must be able to recover from this situation itself, perhaps by creating a new empty database or by duplicating a copy from its application bundle. If your SQLite database is used to store the user's own preferences about how the application should work which change with the user's own preferences, then the file should be stored in the user's Preferences folder. Again, Apple provides an API which will produce the right path for you, and you should never generate it yourself. However storing preferences in a SQLite database is non-standard: Apple already provides a standard mechanism for storing user preferences. If one of these documents disappears between runs of your program then your application must be able to recover from this situation itself, perhaps by creating a new empty database or by duplicating a copy from its application bundle. All of the above is second-nature to any Macintosh programmer. They don't even have to think about this stuff, just like a Windows programmer expects to see their application show up in the Start menu and on the Taskbar. It may be that you should talk to an experienced Mac programmer before porting your application across so you do this and other things in the way a Mac user would expect. >> SQLite itself doesn't care where the database is stored as long as the >> directory it is in is read/write. >> >>> 2. When I done on Windows I should be able to just copy the file and >>> drop it on the Mac HD, right? >> >> Yes. > > Good. Right. SQLite database file format is cross-platform. If you have one that works on one platform, you can just copy it over and it'll work. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users