Android Question Error Code : 2062 (SQLITE_CANTOPEN_EMFILE)

Mark Ryan Penafiel

Member
Licensed User
Longtime User
I have a service that saves information to database every 10 secs.
It stops saying this error

android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 2062)
#################################################################
Error Code : 2062 (SQLITE_CANTOPEN_EMFILE)
Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default.
(unable to open database file (code 2062))

What causes this and how to prevent this like try and catch statement if it encounters such error, it will just do nothing and will wait the next loop schedule. ty
 

drgottjr

Expert
Licensed User
Longtime User
presumably you keep opening the same file over and over until your fd's are exhausted. just off the top of my head, how many times are you initializing sqlite (and where?)? or have you opened the same file over and over, and when it's sqlite's turn there are no more fd's?
 
Upvote 0

Mark Ryan Penafiel

Member
Licensed User
Longtime User
This code ?
SQL1.Initialize(File.DirInternal, "dbs3db", True)

i have 2 service, one everytime the bluetooth is connected, and another every 10 seconds or service start.
should i just put it on service create?

Thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Mark Ryan Penafiel

Member
Licensed User
Longtime User
i move it in the starter service, when i restarted the device, sometime it work, sometime it says , it is not initialized.
It seems that the schedule service starts first before the starter service.
How can i make sure, starter service starts first. Thanks again
 
Upvote 0
Top