android的sqlite的应用程序被强制关闭的设备 [英] android sqlite application is being forcefully closed on device

查看:131
本文介绍了android的sqlite的应用程序被强制关闭的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SQLiteOpenHelper类来创建,打开数据库。我的应用程序我创建这我使用的读取和写入数据到数据库可写的对象SQLiteDatabase。这个对象是静态的主类,并在所有的应用程序用来读取写入数据库。我的应用程序在仿真器正常工作。但设备后,一些读写查询火灾。它为什么发生,请如果任何一个有解决方案,帮助我。

I am using SQLiteOpenHelper class to create, open database. for my application i am creating writable object SQLiteDatabase which i am using to read and write data to database. This object is static for main class and used in all application to read write in to database. my application is working properly on emulator. but on device after some read write query fires. why it is happening, please if any one has solution help me.

推荐答案

我在几个星期前有同样的问题,我发现这个的页面,这到底是什么是错误的。 SQLite的是越野车在Android和实施了错误的方式,所以你不能有线程读取,并在同一时间写入数据库/表。结果
setLockingEnabled()只是不工作,它应该的方式。

I had the same problem a few weeks ago, and I found this page, it's exactly what's wrong. The SQLite is buggy in Android and is implemented the wrong way, so you can't have threads reading and writing to the database/table at the same time.
setLockingEnabled() just dont work the way it's supposed.

我所做的就是运行读取和写入到数据库同步,这意味着你将永远不会有在同一时间读取或写入数据的问题,不管你有多少线程具有的所有方法。

What I did was running all methods that read and write to the db "Synchronized" which means you'll never have a problem with reading or writing data at the same time no matter how many threads you have.

问候
托比亚斯

Regards Tobias

这篇关于android的sqlite的应用程序被强制关闭的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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