openOrCreateDatabase()函数时 出现Failed to open the database错误
来源:互联网 发布:淘宝导航栏全屏代码 编辑:程序博客网 时间:2024/04/30 00:10
在使用SQLiteDatabase.openOrCreateDatabase()函数时 出现Failed to open the database错误,致使数据库打不开。
Filef=context.getDatabasePath("downlog.db");db=SQLiteDatabase.openOrCreateDatabase(FullPath,null);
怀疑是不是因为data/data/xx/databases文件夹不存在所以创建不了数据库,
修改后的代码
File f=context.getDatabasePath("downlog.db").getParentFile(); if(f.exists()==false)f.mkdirs();//注意是mkdirs()有个s 这样可以创建多重目录。 FullPath=f.getPath()+"/downlog.db";db=SQLiteDatabase.openOrCreateDatabase(FullPath,null);
数据库可以正确创建了,这个问题解决了。
不过总觉得有点蹊跷,为什么openOrCreateDatabase(FullPath,null);不会自己创建文件夹呢……
函数不是在activity中使用的,是在service中调用DBHelper类,DBHelper的构造函数中调用的。不知道是不是这个原因。
- openOrCreateDatabase()函数时 出现Failed to open the database错误
- SecureCRT failed to open the host key database file
- Failed to open the host key database file
- PHP使用copy函数复制windows文件时出现failed to open stream: Invalid argument in错误
- 拒绝访问。 Failed to open the WinNT service manager..."错误
- 错误:The request to open "your bundle id" failed
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误
- MySQL导入.sql文件时出现" failed to open file"错误
- IIS进行发布时WCF服务时出现“The underlying provider failed on Open.”错误。
- Win7上安装VPN后连接时提示错误“Failed to open the IPSec driver”
- Metasploit启动时Failed to connect to the database
- Metasploit启动时Failed to connect to the database
- eclipse helios 启动时出现 failed to create the java virtual machine 错误
- git fetch 远程分支
- 常用Windows消息、常量命名参考
- ios简写
- Ubuntu下,安装类似ToitorseSVN的工具:RabbitVCS
- 使用CFile,CArchive,CStdioFile,fstream进行文件操作
- openOrCreateDatabase()函数时 出现Failed to open the database错误
- Android开发原创集
- android 基础知识 十五
- 常用Windows消息、常量命名参考
- RQNOJ-1-明明的随机数
- Linux ifconfig显示详解
- Timer的schedule和scheduleAtFixedRate方法的区别解析
- Apache Mahout
- mysql恢复--flashback