无法在deleteDatabase后创建同名数据库
来源:互联网 发布:淘宝上下架神什么意思 编辑:程序博客网 时间:2024/04/29 19:06
Android开发,遇到一个奇怪的问题,在应用退出的时候,使用deleteDatabase删除sqlite数据库。
然后登录的时候,出现类似os_unix.c stat(/data/data/org.ibuo.demo/databases/demo.db)
android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 1802)的错误。
后来在google code发现已经有人提出了同样的问题:
https://code.google.com/p/android/issues/detail?id=13727
This happened with multiple android versions and devicesI was developing on...I attempted to clear the database when logging out of our app in two different ways:1. Deleting the file under "data/data/MY_APP/databases" directly2. Using context.deleteDatabase();Both of these resulted in the file seeming to be deleted from the file system (it did not show up when listing files from an adb shell).When logging back in however, the old data was still available, and there was no db file created on the file system. SQLiteDatabase.getPath showed we were still looking at the same location however. Using lsof, I determined that the file handle still existed.This is unusual behavior which I would not have expected from the built in Context.deleteDatabase() method, and at least requires some explanation in the docs.Workaround: I solved my problem by dropping all of the tables in the db and setting the version back to 0 instead of using Context.deleteDatabase().=======================
是说被删除的文件的句柄还没有释放。后来用了其他的方法绕过去了这个问题。
在调试的过程中发现,SDK 2.2,2.3会出现数据库已删除,但是却能读出文件的问题。
而4.1,4.2,会直接报错。提示找不到文件的错误。
然后应用会重启,重启后,却可以了。
解决办法:
在deleteDatabase前,把同一句柄的db close掉。
0 0
- 无法在deleteDatabase后创建同名数据库
- 解决IOS8上无法创建同名删除相册的问题
- ie 双击后在桌面创建快捷方式无法打开解决方法
- sql server 2008 无法附加同名数据库错误
- 在Outlook的联系人文件夹下能否创建同名联系人?
- 无法在app_data目录中创建数据库的解决方法
- mysql无法创建数据库
- IDEA创建maven项目后无法在文件目录中创建java文件
- 数据库无法创建数据库视图
- sql server 2005 修改计算机主机名后 ,无法创建数据库发布的解决方法
- sql server 2005 修改计算机主机名后 ,无法创建数据库发布的解决方法
- oracle命令创建数据库和表空间以及安装后本地无法登录问题
- mysql表空间被占用,同名表无法创建或导入
- iOS 无法创建名字跟已删除相册同名的相册问题
- 在创建细粒度审计(FGA)后,ORA-28112: 无法执行策略函数
- 在服务器上创建MQ队列管理器后,本地无法远程连接的问题
- unity中创建UI组件后无法在Scene视图显示
- 针对MySQL5.5版本用%创建用户后在本地(localhost)无法登录的问题
- affine3d affine2d一个demo
- Remove Duplicates from Sorted Array
- log4j自定义html输出日志
- ?软件著作权小结
- leetcode: Letter Combinations of a Phone Number
- 无法在deleteDatabase后创建同名数据库
- Python 学习入门(28)—— 服务器实例
- C++中各种对象的生命周期
- 解决检索COM类工厂中CLSID为{ }组件失败
- 75. 简单来自删减
- nyoj36最长公共子序列--动态规划--初步
- 草根站长的网站推广之路在哪里
- Ubuntu下的解压缩
- 从网站推广细节提升用户体验度