I am confused about database open and close operation for FMDB wrapper class.
Is it creating issue if i open database in
applicationDidFinishLoading method of AppDelegate class
and do not close until application will terminate ?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the Official FMDB documentation:
Opening
Before you can interact with the database, it must be opened. Opening fails if there are insufficient resources or permissions to open and/or create the database.
Closing
When you have finished executing queries and updates on the database, you should close the FMDatabase connection so that SQLite will relinquish any resources it has acquired during the course of its operation.
So, every time your query the Database, you should have a pair of
openandclosecalls on your database.In short, open a DB connection when you require things from database and close it when you are done using the database.
Link to documentation : https://github.com/ccgus/fmdb