not an error (code 0): Could not open the database in read/write mode.的解决办法
2015-05-12 18:01
831 查看
问题 :在项目中,运行到在SD卡创建数据库时遇到了标题所述的错误
原因方面可以看以下这篇文章
http://lifehacker.com/android-kitkat-blocks-some-access-to-micro-sd-cards-1524997895
Android
KitKat Blocks Some Access to Micro SD Cards
里面讲到ANDROID 4.4 后,系统在应用对SD的读写方面做了限制。
应用要读写SD卡,必须申请权限,就算申请了SD卡的读写权限,也只能读在SD卡的共同文件夹。
It can't write to anything on the SD card outside of its designated sandbox.
这句意思大概是 应用不能在指定沙盒外在SD卡写入任何东西,我的理解可能不太到位
上面的情况,有的手机会出现,有的手机不会(同样是4.4以上的系统),不清楚是不是系统定制后产生的差异。
我在项目中还遇到过这种情况,用Intent发起选择图片视频时,无法获取别的应用(比如whatsapp)在SD卡保存的视频,手机没有root,不知道是别的应用对文件或文件夹设置了访问权限,还是因为以上的问题。
不过应用自己在SD卡上写入的图片视频是可以读写的。
解决办法:
不要在SD上创建数据库文件,应该在应用的私有文件夹“/data/data/包名”
下面的文章也给出了几种解决方案,不过有的要root,有的要定制ROM,所以不太实际
http://technofaq.org/posts/2014/04/fixing-external-sd-card-write-issue-on-android-kitkat/
原因方面可以看以下这篇文章
http://lifehacker.com/android-kitkat-blocks-some-access-to-micro-sd-cards-1524997895
Android
KitKat Blocks Some Access to Micro SD Cards
里面讲到ANDROID 4.4 后,系统在应用对SD的读写方面做了限制。
应用要读写SD卡,必须申请权限,就算申请了SD卡的读写权限,也只能读在SD卡的共同文件夹。
It can't write to anything on the SD card outside of its designated sandbox.
这句意思大概是 应用不能在指定沙盒外在SD卡写入任何东西,我的理解可能不太到位
上面的情况,有的手机会出现,有的手机不会(同样是4.4以上的系统),不清楚是不是系统定制后产生的差异。
我在项目中还遇到过这种情况,用Intent发起选择图片视频时,无法获取别的应用(比如whatsapp)在SD卡保存的视频,手机没有root,不知道是别的应用对文件或文件夹设置了访问权限,还是因为以上的问题。
不过应用自己在SD卡上写入的图片视频是可以读写的。
解决办法:
不要在SD上创建数据库文件,应该在应用的私有文件夹“/data/data/包名”
下面的文章也给出了几种解决方案,不过有的要root,有的要定制ROM,所以不太实际
http://technofaq.org/posts/2014/04/fixing-external-sd-card-write-issue-on-android-kitkat/
相关文章推荐
- SQLiteException: not an error (code 0): Could not open the database in read/write mode
- Error: the database could not be exclusively locked to perform the operation[解决办法]
- modelsim10.4仿真错误Error: (vlog-7) Failed to open design unit file "XXXXX" in read mode解决办法
- 使用Spring提供的Open Session In View而引起Write operations are not allowed in read-only mode (FlushMode.NEVER) 错误解决
- Error:Could not initialize class com.android.ide.common.util.ReadWriteProcessLock 解决办法
- 打开struts-config.xml 报错 解决办法Could not open the editor
- 改主机名后启weblogic失败,Could not obtain the localhost address. The most likely cause is an error in the ne
- ORA-16433: The database must be opened in read/write mode
- 配置YUM源出现Errno 14 Could not open/read repomd.xml 错误的解决办法
- qt4.7中Could not find make command: mingw32-make.exe in the build environment的解决办法
- Yii “CDbConnection failed to open the DB connection: could not find driver"解决办法
- Note: This element has no attached source and Javadoc could not be found in the attached Javadoc解决办法
- MyEclipse Servers视窗出现“Could not create the view: An unexpected exception was thrown”错误解决办法
- an error occurred while creating opening the c++ browsing database 解决办法
- [Solved]: System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use.
- Yii “CDbConnection failed to open the DB connection: could not find driver"解决办法
- 配置YUM源出现Errno 14 Could not open/read repomd.xml 错误的解决办法
- 安装、重装MySQL时,出现could not start the service mysql error:0的解决办法
- Could not install the app on the device, read the error above for details. Make sure you have an And
- Error: The INF file contains Unicode characters that could not be converted correctly to ANSI 解决办法