In my app I\'ve got to implement some UI and Sync service. It runs in the background and updates data. Sync service is not very simple, it uses multithreading.
So, here
Use a singleton helper for opening connections.
1) Open as many readable connections as you want, and close then after your are done with it.
2) For writable connections, you should open only a single writable connection.
When attempting to open another writable connection, return the already opened connection. If no writable connection exists, open a new writable connection. Keep a writable_connection counter, and close the writable connection, when all threads are done with it.
I am about to implement this, and will let you all know if it works when I am done.