Example usage for android.database.sqlite SQLiteDatabase setLockingEnabled

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

Introduction

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

Prototype

@Deprecated
public void setLockingEnabled(boolean lockingEnabled) 

Source Link

Document

Control whether or not the SQLiteDatabase is made thread-safe by using locks around critical sections.

Usage

From source file:mobisocial.bento.anyshare.util.DBHelper.java

@Override
public void onOpen(SQLiteDatabase db) {
    // enable locking so we can safely share 
    // this instance around
    db.setLockingEnabled(true);
    //        Log.w(TAG, "dbhelper onopen");
}

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

@Override
public void onOpen(SQLiteDatabase db) {
    // enable locking so we can safely share 
    // this instance around
    db.setLockingEnabled(true);
    Log.w(TAG, "dbhelper onopen");
}

From source file:org.ttrssreader.controllers.DBHelper.java

@SuppressWarnings("deprecation")
private synchronized boolean initializeDBHelper() {
    final Context context = contextRef.get();
    if (context == null) {
        Log.e(TAG, "Can't handle internal DB without Context-Object.");
        return false;
    }/*from w w w  .j  ava 2  s. co  m*/

    if (getOpenHelper() != null)
        closeDB();

    openHelper = new OpenHelper(context);
    SQLiteDatabase db = openHelper.getWritableDatabase();

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        db.setLockingEnabled(true);

    if (specialUpgradeSuccessful) {
        // Re-open DB for final usage:
        closeDB();
        openHelper = new OpenHelper(context);
        db = openHelper.getWritableDatabase();

        Toast.makeText(context, "ImageCache is beeing cleaned...", Toast.LENGTH_LONG).show();
        new org.ttrssreader.utils.AsyncTask<Void, Void, Void>() {
            protected Void doInBackground(Void... params) {
                // Clear ImageCache since no files are in REMOTE_FILES anymore and we dont want to leave them
                // there forever:
                ImageCache imageCache = Controller.getInstance().getImageCache();
                imageCache.fillMemoryCacheFromDisk();
                File cacheFolder = new File(imageCache.getDiskCacheDirectory());
                if (cacheFolder.isDirectory()) {
                    try {
                        FileUtils.deleteDirectory(cacheFolder);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return null;
            }

            protected void onPostExecute(Void result) {
                Toast.makeText(context, "ImageCache has been cleaned up...", Toast.LENGTH_LONG).show();
            }
        }.execute();
    }

    insertCategory = db.compileStatement(INSERT_CATEGORY);
    insertFeed = db.compileStatement(INSERT_FEED);
    insertArticle = db.compileStatement(INSERT_ARTICLE);
    insertLabel = db.compileStatement(INSERT_LABEL);
    insertRemoteFile = db.compileStatement(INSERT_REMOTEFILE);
    insertRemoteFile2Article = db.compileStatement(INSERT_REMOTEFILE2ARTICLE);

    db.acquireReference();
    initialized = true;
    return true;
}