Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLiteOpenHelper Application has opened too many files

I am facing a problem with my android app. I am running into this issue:

SQLiteOpenHelper: Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default.

(unknown error (code 2062): Could not open database)

What could be the possible cause of this issue? Thanks so much for ya help!

like image 943
Tong Jun Qun Avatar asked Sep 25 '22 19:09

Tong Jun Qun


1 Answers

I ran across the same problem and I managed to solve it by closing the cursor by calling the following where I left it open:

cursor.close();

I was creating a new object of the Cursor class inside a loop without closing it. While on small loop iterations it was working fine, after the data got bigger and the loop iterations too then I started seeing this problem.

Also as it is suggested in the comments of the questioner, make sure you close any object of the SQlite database as soon as you are finished.

like image 141
Darush Avatar answered Oct 11 '22 15:10

Darush