Search in sources :

Example 1 with SQLiteDatabaseLockedException

use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.

the class ActivityDataSource method insertMultiple.

private synchronized int insertMultiple(ContentValues[] allValues) {
    int rowsAdded = 0;
    long rowId;
    ContentValues values;
    if (database == null || !database.isOpen()) {
        open();
    }
    try {
        database.beginTransaction();
        for (ContentValues initialValues : allValues) {
            values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
            try {
                rowId = database.insert(ActivitySQLiteHelper.TABLE_ACTIVITY, null, values);
            } catch (IllegalStateException e) {
                return rowsAdded;
            }
            if (rowId > 0)
                rowsAdded++;
        }
        database.setTransactionSuccessful();
    } catch (NullPointerException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (SQLiteDatabaseLockedException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (IllegalStateException e) {
        // caught setting up the transaction I guess, shouldn't ever happen now.
        e.printStackTrace();
        return rowsAdded;
    } finally {
        try {
            database.endTransaction();
        } catch (Exception e) {
        // shouldn't happen unless it gets caught above from an illegal state
        }
    }
    return rowsAdded;
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException) SQLException(android.database.SQLException) TwitterException(twitter4j.TwitterException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Example 2 with SQLiteDatabaseLockedException

use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.

the class ListDataSource method insertMultiple.

private synchronized int insertMultiple(ContentValues[] allValues) {
    int rowsAdded = 0;
    long rowId;
    ContentValues values;
    if (database == null || !database.isOpen()) {
        open();
    }
    try {
        database.beginTransaction();
        for (ContentValues initialValues : allValues) {
            values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
            try {
                rowId = database.insert(ListSQLiteHelper.TABLE_HOME, null, values);
            } catch (IllegalStateException e) {
                return rowsAdded;
            }
            if (rowId > 0)
                rowsAdded++;
        }
        database.setTransactionSuccessful();
    } catch (NullPointerException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (SQLiteDatabaseLockedException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (IllegalStateException e) {
        // caught setting up the transaction I guess, shouldn't ever happen now.
        e.printStackTrace();
        return rowsAdded;
    } finally {
        try {
            database.endTransaction();
        } catch (Exception e) {
        // shouldn't happen unless it gets caught above from an illegal state
        }
    }
    return rowsAdded;
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException) SQLException(android.database.SQLException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Example 3 with SQLiteDatabaseLockedException

use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.

the class MentionsDataSource method insertMultiple.

private synchronized int insertMultiple(ContentValues[] allValues) {
    int rowsAdded = 0;
    long rowId;
    ContentValues values;
    if (database == null || !database.isOpen()) {
        open();
    }
    try {
        database.beginTransaction();
        for (ContentValues initialValues : allValues) {
            values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
            try {
                rowId = database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
            } catch (IllegalStateException e) {
                return rowsAdded;
            }
            if (rowId > 0)
                rowsAdded++;
        }
        database.setTransactionSuccessful();
    } catch (NullPointerException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (SQLiteDatabaseLockedException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (IllegalStateException e) {
        // caught setting up the transaction I guess, shouldn't ever happen now.
        e.printStackTrace();
        return rowsAdded;
    } finally {
        try {
            database.endTransaction();
        } catch (Exception e) {
        // shouldn't happen unless it gets caught above from an illegal state
        }
    }
    return rowsAdded;
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException) SQLException(android.database.SQLException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Example 4 with SQLiteDatabaseLockedException

use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.

the class HomeContentProvider method insertMultiple.

private int insertMultiple(ContentValues[] allValues) {
    int rowsAdded = 0;
    long rowId;
    ContentValues values;
    SQLiteDatabase db = HomeDataSource.getInstance(getContext()).getDatabase();
    try {
        db.beginTransaction();
        for (ContentValues initialValues : allValues) {
            values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
            try {
                rowId = db.insert(HomeSQLiteHelper.TABLE_HOME, null, values);
            } catch (IllegalStateException e) {
                return rowsAdded;
            //db = HomeDataSource.getInstance(context).getDatabase();
            //rowId = 0;
            }
            if (rowId > 0)
                rowsAdded++;
        }
        db.setTransactionSuccessful();
    } catch (NullPointerException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (SQLiteDatabaseLockedException e) {
        e.printStackTrace();
        return rowsAdded;
    } catch (IllegalStateException e) {
        // caught setting up the transaction I guess, shouldn't ever happen now.
        e.printStackTrace();
        return rowsAdded;
    } finally {
        try {
            db.endTransaction();
        } catch (Exception e) {
        // shouldn't happen unless it gets caught above from an illegal state
        }
    }
    return rowsAdded;
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Aggregations

ContentValues (android.content.ContentValues)4 SQLiteDatabaseLockedException (android.database.sqlite.SQLiteDatabaseLockedException)4 SQLException (android.database.SQLException)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 TwitterException (twitter4j.TwitterException)1