Cursor for db query must be closed

I can compile and run the App from master branch, but the one from develop branch keeps crashing. A search of the LogCat Error message tells me that the cursors must be closed.

I have a very large account tree imported from a desktop program, resulting in a lot of db queries and left a lot of cursors open. It soon ran out of resource.

So I made the following changes, and now the App (compiled from the develop branch) runs much more stable on my phone.