Closed arashcoder closed 7 years ago
Generally speaking, it's better to use a singleton of your subclass of SquidDatabase
(or rather, one instance for each individual database file--I'm assuming all your instances refer to the same file, in which case I suggest having just one instance instead.).
@arashcoder to answer your other question -- if your database is an app-wide singleton (as it should be), you don't need to worry about closing the db. The db will open itself the first time you read from or write your database instance, and it's cheaper to just leave it open at that point. If you make your db instance a singleton and don't bother with closing it, it should eliminate your "connection leaked" warnings.
Also for any future questions, you can join our Gitter chat for support.
Thank you for the clarification.
Hi. Thanks for this wonderful library. I was wondering what is the proper way of initializing and closing db. Whenever I need to access the database I make new instance of MyDatabase (which inherits from SquidDatabase). Should I use a singleton for the whole application? And I get this warning very often: "A SQLiteConnection object for database 'my-database_db' was leaked." Thanks.