Hey guys, I got his situation.
When my app runs for the first time, I gather some data from the user which is saved in a sqlite DB.
Later, every time the app will run will load that data.
Now, let’s assume for some reason the DB file gets lost (or unreadable). For that, I made some checks that will warn the user about this unusual condition and will eventually launch a search window or re initialize the app.
The question is… how do I avoid this from happening the first time the program is run ? It will not find the DB, and will trigger the “missing config file” warning…
Thanks a lot.
Its a matter of you app “Cannot know what it doesn’t know”
All it does know is the file is missing… It doesn’t know if it ever was there, unless you have a 2nd file that says the first file had in fact been there, but then what happens if THAT file is deleted? etcc… etc… etc…
- Don’t “tell” the user about the file. Don’t hide it… just don’t mention it
- Then handle the missing file one way… “The system has detected this app has not yet been configured” … period
Good point by Dave.
Is there a “known” folderitem to the sqlite DB stored in your preferences file, which could may be nil?
A preferences system might at least tell you if it’s ever been run before and where your database is. If you expect users to move it around that would be the best way of doing it. Can get messy if the users move the file a lot.
If the users should never move it then I’d put it in ApplicationSupport and if it’s not there do your initialization again. That’s easy enough to implement.
Not sure I understood you Detlef… I’ll probably take Dave’s advice…