Android的SQLite的错误code 21 [英] Android SQLite error code 21

查看:834
本文介绍了Android的SQLite的错误code 21的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了以下错误在我的仿真器的日志文件,我不知道该怎么做的,因为谷歌搜索变成了什么。

 十二月三号至12日:53:28.782:信息/数据库(688):源码返回:错误code = 21,
  味精=误用检测到源代码行95716
12月3号至一十二日:53:28.812:ERROR /数据库(688):sqlite_config失败ERROR_ code = 21。
  这应该不会发生。
 

解决方案

我发现

 的#define SQLITE_MISUSE使用21 / *库不正确* /
 

SQLite的C / C ++接口文档

  

可能会出现此错误,如果一个或多个   的SQLite的API例程用于   不正确。不正确的示例   使用包括调用sqlite_exec   数据库已被关闭后   使用sqlite_close或调用   sqlite_exec使用相同的数据库   从两个同时指针   单独的线程。

我想这意味着你的code调用该接口库不正确地围绕线95716。

之后。 。

的OP确认实际的问题涉及两个线程同时访问数据库,一个都试图写入分贝,而另一个试图将其关闭。我推断这一点,对code,95716,违规行是在模拟器。 (因为OP的code碱基只有1000线以下。)

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.

解决方案

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.)

这篇关于Android的SQLite的错误code 21的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆