开放式数据库ReadWirte无法在特定的设备 [英] Open Database for ReadWirte not possible on specific device

查看:424
本文介绍了开放式数据库ReadWirte无法在特定的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是尝试打开READWRITE模式的数据库。我得到以下错误:不是一个错误(code 0):无法打开在读/写模式的数据库。当打开数据库的方式相同,但readonly是被作品。在我3设备,这不是一个问题,开口READWRITE,但2用户报告以下错误。

该数据库存在于用户的文件系统。我检查这与file.exists() - >确定。 该数据库文件的读写能力的用户设备上。我检查这与file.canWrite() - >确定

在DBFILE存储下:

StoragePath:/mnt/extSdCard/mypath/mydb.db

新信息对2014年9月3日:这似乎是在奇巧4.4.2只有一个问题。由于用户已经更新到4.4.2,他们得到了这个问题。

我的code:

 公共无效的onCreate(包savedInstanceState){


connectWriter(); //下面抛出异常。

公共无效connectWriter(){
        chronica_connection_readwrite = SQLiteDatabase.openDatabase(mypath中,空,SQLiteDatabase.OPEN_READWRITE);
        //chronica_connection_read.enableWriteAheadLogging();
    }
 

异常报告:

 了java.lang.RuntimeException:无法启动活动ComponentInfo {...}:android.database.sqlite.SQLiteException:不是错误(code 0):无法打开以读/写模式数据库。
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
在android.app.ActivityThread.access $ 800(ActivityThread.java:157)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1247)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:157)
在android.app.ActivityThread.main(ActivityThread.java:5293)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1265)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
在dalvik.system.NativeStart.main(本机方法)
致:android.database.sqlite.SQLiteException:不是错误(code 0):无法打开在读/写模式的数据库。
在android.database.sqlite.SQLiteConnection.nativeOpen(本机方法)
在android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:342)
在android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:232)
在android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
在android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
在android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
在android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:891)
在android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:859)
在android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
在android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:671)
在myclass.connectWriter(ChronicBrowser.java:14286)
在myclass.LoadModule(ChronicBrowser.java:10792)
在myclass.onCreate(ChronicBrowser.java:761)
在android.app.Activity.performCreate(Activity.java:5389)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)


************设备信息***********
品牌:三星
设备:HLTE
型号:SM-N9005
编号:KOT49H
产品:hltexx

************ 固件 ************
SDK:19
发布:4.4.2
增量:N9005XXUENB7
 

解决方案

看起来,这不是错误,而是功能。

谷歌的奇巧阻止某些访问的Micro SD卡

这是很可悲的,但看起来像真正的

I simply try to open a database in READWRITE Mode. I get the following error: "not an error (code 0): Could not open the database in read/write mode." When opening the DB the same way but READONLY is works. On my 3 devices this is not a problem opening in READWRITE, but 2 users reported that following error.

the db exists on the users filesystem . I check this with file.exists() -> ok. the db-file is readwrite able on the users device. I check this with file.canWrite() -> ok.

the dbfile is stored under :

StoragePath : /mnt/extSdCard/mypath/mydb.db

New Info on 09.03.2014 : It seems to be only a problem in KitKat 4.4.2. Since Users have updated to 4.4.2 they get this problem.

My Code:

public void onCreate(Bundle savedInstanceState) {


connectWriter(); // throws exception below.

public void connectWriter() {
        chronica_connection_readwrite = SQLiteDatabase.openDatabase("MyPath", null, SQLiteDatabase.OPEN_READWRITE);
        //chronica_connection_read.enableWriteAheadLogging();
    }

Exception Report:

java.lang.RuntimeException: Unable to start activity ComponentInfo{...}: android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
at android.app.ActivityThread.access$800(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode.
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:342)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:232)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:891)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:859)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:671)
at myclass.connectWriter(ChronicBrowser.java:14286)
at myclass.LoadModule(ChronicBrowser.java:10792)
at myclass.onCreate(ChronicBrowser.java:761)
at android.app.Activity.performCreate(Activity.java:5389)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)


************ DEVICE INFORMATION ***********
Brand: samsung
Device: hlte
Model: SM-N9005
Id: KOT49H
Product: hltexx

************ FIRMWARE ************
SDK: 19
Release: 4.4.2
Incremental: N9005XXUENB7 

解决方案

Looks like that this is not bug, but "feature".

Google's KitKat Blocks Some Access to Micro SD Cards

It's really sad, but looks like true

这篇关于开放式数据库ReadWirte无法在特定的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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