Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SQLite error code 21

Tags:

android

sqlite

I've gotten the following error in the log files of my emulator and I don't know what to make of it because a google search turns up nothing.

03-12 12:53:28.782: INFO/Database(688): sqlite returned: error code = 21, 
  msg = misuse detected by source line 95716
03-12 12:53:28.812: ERROR/Database(688): sqlite_config failed error_code = 21. 
  THIS SHOULD NEVER occur.
like image 350
David K. Avatar asked Feb 24 '23 20:02

David K.


1 Answers

I found

#define SQLITE_MISUSE      21   /* Library used incorrectly */

in the SQLite C/C++ interface documentation.

This error might occur if one or more of the SQLite API routines is used incorrectly. Examples of incorrect usage include calling sqlite_exec after the database has been closed using sqlite_close or calling sqlite_exec with the same database pointer simultaneously from two separate threads.

I'd guess that means your code is calling the interface library incorrectly around line 95716.

Later . . .

The OP confirmed that the actual problem involved two threads accessing the database at the same time, one trying to write to the db, and the other trying to close it. I'd infer from this that the offending line of code, 95716, was in the emulator. (Because the OP's code base had only 1000 lines or less.)

like image 53
Mike Sherrill 'Cat Recall' Avatar answered Mar 08 '23 15:03

Mike Sherrill 'Cat Recall'