Android的SQLite的 - 改变journal_mode [英] Android SQLite - changing journal_mode

查看:1301
本文介绍了Android的SQLite的 - 改变journal_mode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变我的数据库journal_mode,通过code。我试图SQLiteDatabase.execSQL(PRAGMA journal_mode = OFF),而是因为,前pressionPRAGMA journal_mode = OFF返回结果(我证实了这一来自终端),并因此Android认为这是一个查询失败并抱怨说我应该使用替代的ExecQuery。但我想执行不查询。

I am trying to alter the journal_mode for my database, through code. I tried SQLiteDatabase.execSQL("PRAGMA journal_mode=OFF") but it fails because, the expression "PRAGMA journal_mode=OFF" returns a result (I verified this from the terminal), and so Android thinks this is a query and complains that I should be using execQuery instead. But what I am trying to execute isn't a query.

我也试过编译编译前pression到SQLiteStatement并调用execute方法,但同样的结果。

I also tried compiling the pragma expression to a SQLiteStatement and invoked the execute method, but same result.

有人建议任何替代,使通过code这个工作呢?

Can someone suggest any alternatives to make this work through code?

谢谢,
兰吉特

Thanks, Ranjit

推荐答案

也许你是从这个问题的痛苦的<一个href=\"http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#execSQL%28java.lang.String%29\"相对=nofollow> execSQL文档谈:

Perhaps you are suffering from this problem that the execSQL docs talk about:

在使用enableWriteAheadLogging(,journal_mode自动此类管理。所以,千万不要,如果你的应用程序使用enableWriteAheadLogging使用PRAGMA journal_mode'语句设置journal_mode()

When using enableWriteAheadLogging(), journal_mode is automatically managed by this class. So, do not set journal_mode using "PRAGMA journal_mode'" statement if your app is using enableWriteAheadLogging()

检查您不使用预写日志,然后它可能工作。

Check that you are not using write ahead logging and then it might work.

这篇关于Android的SQLite的 - 改变journal_mode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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