本文介绍了使用内存中的sqlite android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我一直在阅读,浏览,搜索很多相关内容,我多次来回穿越stackoverflow,并且设法设法缩小了问题的范围.


I've been reading, browsing, searching a lot on this, I've criss-crossed stackoverflow back and forth many times and I managed to narrow my problem as much as I could.

我唯一不了解的是如何完全使用内存中的SQLite数据库.

The only thing I do not understand, is how to fully use an in-memory SQLite database.

这是我的情况-我有一个加密的SQLite数据库,该数据库在加载应用程序时会解密(这部分肯定可以工作).与数据库交互的类肯定可以在普通数据库中正常工作.简而言之,使用从内部电话内存加载的普通数据库,一切都是完美的,但是我不确定如何或在何处将解密后的数据库存储在内存中,以便将其解释为普通数据库.

Here is my situation - I have an encrypted SQLite database which I decrypt during the loading of my application (this part works for sure). My class that interacts with the database works for sure with a plain database.So to make it short, everything is flawless with a plain DB which gets loaded from the internal phone memory, but I am not sure how or where to store the decrypted DB in memory so it would get interpreted as normal DB.

我想我应该在super(context, null, null, 3);中放置null而不是名称,并在SQLiteDatabase.openDatabase()中使用:memory:而不是路径,但是我还是不太了解.它说它找不到android_metadata表,但是我确定数据库是应该的.

I guess I should put null instead of a name in super(context, null, null, 3); and use :memory: instead of a path in SQLiteDatabase.openDatabase(), but I still don't understand fully. It says it cannot find an android_metadata table, but I am certain the database is as it should be.

希望我对此很清楚:)

推荐答案

将创建一个内存数据库.请注意,它将在您调用getWritableDatabase()时创建.

SQLiteOpenHelper() will create an in-memory database if the name is null. Note that it will be created when you invoke getWritableDatabase().

然后您应该插入数据.

这篇关于使用内存中的sqlite android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 06:27