在iOS中,我使用原生SQLite库打开数据库,如下所示:
sqlite3_open_v2([[self getDatabasePath] UTF8String], &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX
最后一个标志SQLITE_OPEN_FULLMUTEX就是我要找的。 p>
在Android中有没有办法像这样打开数据库?我找到了以下内容:
mDatabase = SQLiteDatabase.openDatabase("dd", null, SQLiteDatabase.OPEN_READWRITE);
我检查了类定义,他们拥有的所有标志是:
public static final int CONFLICT_ROLLBACK = 1;
public static final int CONFLICT_ABORT = 2;
public static final int CONFLICT_FAIL = 3;
public static final int CONFLICT_IGNORE = 4;
public static final int CONFLICT_REPLACE = 5;
public static final int CONFLICT_NONE = 0;
public static final int SQLITE_MAX_LIKE_PATTERN_LENGTH = 50000;
public static final int OPEN_READWRITE = 0;
public static final int OPEN_READONLY = 1;
public static final int NO_LOCALIZED_COLLATORS = 16;
public static final int CREATE_IF_NECESSARY = 268435456;
所以,我在核心SQLite库中看不到这个选项。关于如何用这个标志打开数据库的任何想法?
答案 0 :(得分:-1)
Android Sqlite数据库默认是线程安全的,这是android而不是ios的美: - )
BTW看看:Is Sqlite Database instance thread safe
但请确保打开和关闭数据库,因为很快就会出现内存泄漏。
http://www.androiddesignpatterns.com/2012/05/correctly-managing-your-sqlite-database.html