Example usage for android.database.sqlite SQLiteDatabase NO_LOCALIZED_COLLATORS

List of usage examples for android.database.sqlite SQLiteDatabase NO_LOCALIZED_COLLATORS

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase NO_LOCALIZED_COLLATORS.

Prototype

int NO_LOCALIZED_COLLATORS

To view the source code for android.database.sqlite SQLiteDatabase NO_LOCALIZED_COLLATORS.

Click Source Link

Document

Open flag: Flag for #openDatabase to open the database without support for localized collators.

Usage

From source file:me.piebridge.bible.Bible.java

public boolean setVersion(String version) {
    if (version == null) {
        return false;
    }/*from www .j ava 2 s .c om*/
    File file = getFile(version);
    if (file == null || !file.isFile()) {
        if ("".equals(databaseVersion)) {
            return setDefaultVersion();
        } else {
            return false;
        }
    }
    if (database != null) {
        if (databaseVersion.equals(version)) {
            return true;
        }
        Log.d(TAG, "close database \"" + database.getPath() + "\"");
        database.close();
    }
    databaseVersion = version;
    try {
        database = SQLiteDatabase.openDatabase(file.getAbsolutePath(), null,
                SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
        Log.d(TAG, "open database \"" + database.getPath() + "\"");
        int oldsize = allhuman.size();
        setMetadata(database, databaseVersion, true);
        if (allhuman.size() > oldsize) {
            SharedPreferences.Editor editor = mContext
                    .getSharedPreferences(HUMAN_PREFERENCE, Context.MODE_MULTI_PROCESS).edit();
            for (Entry<String, String> entry : allhuman.entrySet()) {
                editor.putString(entry.getKey(), entry.getValue());
            }
            editor.commit();
        }
        return true;
    } catch (Exception e) {
        try {
            file.delete();
        } catch (Exception f) {
        }
        return setDefaultVersion();
    }
}

From source file:com.androzic.location.LocationService.java

private void openDatabase() {
    Androzic application = Androzic.getApplication();
    if (application.dataPath == null) {
        Log.e(TAG, "Data path is null");
        errorMsg = "Data path is null";
        errorTime = System.currentTimeMillis();
        updateNotification();/*from   w w w  .j a va  2 s .  c om*/
        return;
    }
    File dir = new File(application.dataPath);
    if (!dir.exists() && !dir.mkdirs()) {
        Log.e(TAG, "Failed to create data folder");
        errorMsg = "Failed to create data folder";
        errorTime = System.currentTimeMillis();
        updateNotification();
        return;
    }
    File path = new File(dir, "myTrack.db");
    try {
        trackDB = SQLiteDatabase.openDatabase(path.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE
                | SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
        Cursor cursor = trackDB.rawQuery("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name = 'track'",
                null);
        if (cursor.getCount() == 0) {
            trackDB.execSQL(
                    "CREATE TABLE track (_id INTEGER PRIMARY KEY, latitude REAL, longitude REAL, code INTEGER, elevation REAL, speed REAL, track REAL, accuracy REAL, datetime INTEGER)");
        }
        cursor.close();
    } catch (SQLiteException e) {
        trackDB = null;
        Log.e(TAG, "openDatabase", e);
        errorMsg = "Failed to open DB";
        errorTime = System.currentTimeMillis();
        updateNotification();
    }
}

From source file:me.piebridge.bible.Bible.java

private boolean checkVersionMeta(File file, String version) {
    SQLiteDatabase metadata = null;//from  w w  w . j  a v  a 2s.  co  m
    try {
        metadata = SQLiteDatabase.openDatabase(file.getAbsolutePath(), null,
                SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
        String dataversion = version.replace("demo", "");
        if (!versionFullnames.containsKey(version)) {
            versionFullnames.put(version, getVersionMetadata("fullname", metadata, dataversion));
        }
        if (!versionNames.containsKey(version)) {
            versionNames.put(version, getVersionMetadata("name", metadata, dataversion));
        }
        versionDates.put(version, getVersionMetadata("date", metadata, "0"));
        // setMetadata(metadata, dataversion, false);
        return true;
    } catch (Exception e) {
        try {
            file.delete();
        } catch (Exception f) {
        }
        return false;
    } finally {
        if (metadata != null) {
            metadata.close();
        }
    }
}