0

In iOS I use native SQLite library to open database as follows:

sqlite3_open_v2([[self getDatabasePath] UTF8String], &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX

Last flag SQLITE_OPEN_FULLMUTEX is what I'm looking for.

Is there a way in Android to open database like this? I found following:

mDatabase = SQLiteDatabase.openDatabase("dd", null, SQLiteDatabase.OPEN_READWRITE);

I checked class definition and all flags they have is:

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;

So, I see nothing like this option in core SQLite library. Any ideas on how I can open DB with this flag?

katit
  • 17,375
  • 35
  • 128
  • 256

1 Answers1

-1

Android Sqlite database is thread safe by default, and this is the beauty of android rather ios :-)

BTW look at:

Is Sqlite Database instance thread safe

but make sure about opening and closing db because you will get memory leak very soon.

http://www.androiddesignpatterns.com/2012/05/correctly-managing-your-sqlite-database.html

Community
  • 1
  • 1
mmlooloo
  • 18,937
  • 5
  • 45
  • 64