android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database
在开发一个app的过程中,使用了Provider,通过install 的方式将APP运行在机器上,再通过setting清除该APP再运行APP,一切仍正常,但若通过系统签名将app push到system/app上,再在setting上清除该APP的数据,再运行就发生了android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database。 同样的code为什么通过不同的方式就会有问题呢?我纠结了好久,先从代码去分析mOpenHelper.getWritableDatabase()它会检查数据库是否存在,如果不存在就会创建。但是我到/data/data/com...../databases/下却没有DB,而mOpenHelper.getWritableDatabase()返回DB不为空。再insert的时候就会发生attempt to write a readonly database!为何明明数据库不存在了,但仍返回不为空的DB??
接着我下载了一个Provider Demo做了系统签名并push 到system/app上,按照那测试路径,发现仍正常!太不可思议了!!
然后做了很多尝试,都没有找到原因...
为了赶出code,采取了一种很暴力的方式解决,就是
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
File database=new File("/data/data/com.lewa.updater/databases");
if(!database.exists()&&db!=null){
db.close();
db = mOpenHelper.getWritableDatabase();
}
上了code接着解决另外一个关于写文件需要权限的bug,这也是很难啃的一个,折腾了一晚上都没有解决,但无意让我发现了上一个bug的原因,发现了我的app和provide demo 的app差别在于这里
<application
android:name="com...."
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.Style"
android:persistent="true" >
这行
android:persistent="true",我把这行加入到demo里面,果真,android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database发生了,然后查阅了
http://www.cnblogs.com/perseus/archive/2012/01/11/2319660.html这文章,就解释了上面那一切了。
oh! My God!
分享到:
相关推荐
赠送jar包:sqlite-jdbc-3.34.0.jar; 赠送原API文档:sqlite-jdbc-3.34.0-javadoc.jar; 赠送源代码:sqlite-jdbc-3.34.0-sources.jar; 赠送Maven依赖信息文件:sqlite-jdbc-3.34.0.pom; 包含翻译后的API文档:...
import android.database.sqlite.SQLiteDatabase.CursorFactory; /** * *@author Administrator DataBaseHelper是一个访问SQLite的助类,提供两个方面的功能 * 1.getReadableDatebase(),getWriteableDatabase()...
SQLite.Interop.dll for sqlite expert professional 4.2 用与SQLite Expert打开本地已加密的数据库的插件。1.将SQLite.Interop.dll x86拷贝到SQLite Expert安装路径(如:x:\Program Files (x86)\SQLite Expert\...
.net sqlite_1.0.76.0里面包括: System.Data.SQLite.dll System.Data.SQLite.dll类库文档 sqlite-doc-3070800文档
DB.Browser.for.SQLite-3.12.0-win64 一个sqlite连接工具20200821
SQLite.Interop.dll 32和64位文件,配合SQLite Expert Professional 4.2可以打开加密数据库。 将SQLite.Interop.dll拷贝到SQLite Expert安装路径,然后打开SQLite Expert,Tools --> Options --> SQLite Library中...
gcc使用的sqlite3数据库,sqlite3.a ,可以用于Dev-C++,也可以用于Windows下使用gcc编译的程序,sqlite版本是:3270200,还包含了sqlite3.lib库文件,可以用于visual studio。
这是一个DB.Browser.for.SQLite-3.10.1-win64.exe,用来对SQLite的数据库进行操作。本人将它运行在Window x64环境下。
This book takes a hands-on, example-based approach to help readers understand the core topics of SQLite and Android database-driven applications. This book focuses on providing you with latent as well...
Hibernate连接SQLite配置步骤: 1、添加SQLite库: 1.1、将两个jar包:com.zy.hibernate.dialect.SQLiteDialect.jar、sqlite-jdbc-3.7.2.jar拷贝到“\WEB-INF\lib”文件夹下; 2、配置hibernate: 2.1、将...
sqlite-jdbc-3.32.3-sources.jar;嵌入式数据库sqlite的源码,喜欢的可以看看。
Stroud reviews the core database theory and SQL techniques you need to efficiently build, manipulate, and read SQLite databases. He explores SQLite in detail, illuminates Android’s APIs for database ...
DB.Browser.for.SQLite-3.12.1-win64-v2.msi
The.Definitive.Guide.to.SQLite sqlite3的最好教学图书pdf包括各种语言接口,适合移动设备,嵌入式设备开发
将当前说明文档的目录下的x64、x86目录和System.Data.SQLite.dll文件复制到您的应用程序根目录中(注意更新引用)。 如果是WEB网站,则复制到Bin目录下即可,发布时,也注意x64和x86一起打包发布 注意,当前的...
将当前说明文档的目录下的x64、x86目录和System.Data.SQLite.dll文件复制到您的应用程序根目录中(注意更新引用)。 如果是WEB网站,则复制到Bin目录下即可,发布时,也注意x64和x86一起打包发布 之前找了很久才...
System.Data.SQLite.DLL C# 读写sqlite数据库 亲测可用 不能读取加密的sqlite数据库
SQLite数据库查看工具,用于Android项目中databases的数据库操作。DB Browser for SQLite 是一个高品质,可视化,开放源码的工具。用于创建,设计和编辑SQLite兼容的数据库文件。它适用于希望创建数据库,检索和编辑...
import android.database.sqlite.SQLiteCursor; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import ...
版本号为V1.0.111.0的System.Data.SQLite.DLL & SQLite.Interop.DLL,兼容x86和x64,直接引入项目即可