Search in sources :

Example 1 with SQLException

use of android.database.SQLException in project cw-omnibus by commonsguy.

the class Provider method insert.

@Override
public Uri insert(Uri url, ContentValues initialValues) {
    long rowID = db.getWritableDatabase().insert(TABLE, Constants.TITLE, initialValues);
    if (rowID > 0) {
        Uri uri = ContentUris.withAppendedId(Provider.Constants.CONTENT_URI, rowID);
        getContext().getContentResolver().notifyChange(uri, null);
        return (uri);
    }
    throw new SQLException("Failed to insert row into " + url);
}
Also used : SQLException(android.database.SQLException) Uri(android.net.Uri)

Example 2 with SQLException

use of android.database.SQLException in project cw-advandroid by commonsguy.

the class Provider method insert.

@Override
public Uri insert(Uri url, ContentValues initialValues) {
    long rowID = db.getWritableDatabase().insert(TABLE, Constants.TITLE, initialValues);
    if (rowID > 0) {
        Uri uri = ContentUris.withAppendedId(Provider.Constants.CONTENT_URI, rowID);
        getContext().getContentResolver().notifyChange(uri, null);
        return (uri);
    }
    throw new SQLException("Failed to insert row into " + url);
}
Also used : SQLException(android.database.SQLException) Uri(android.net.Uri)

Example 3 with SQLException

use of android.database.SQLException in project cw-advandroid by commonsguy.

the class Provider method insert.

@Override
public Uri insert(Uri url, ContentValues initialValues) {
    long rowID = db.getWritableDatabase().insert(TABLE, Constants.TITLE, initialValues);
    if (rowID > 0) {
        Uri uri = ContentUris.withAppendedId(Provider.Constants.CONTENT_URI, rowID);
        getContext().getContentResolver().notifyChange(uri, null);
        return (uri);
    }
    throw new SQLException("Failed to insert row into " + url);
}
Also used : SQLException(android.database.SQLException) Uri(android.net.Uri)

Example 4 with SQLException

use of android.database.SQLException in project cw-advandroid by commonsguy.

the class Provider method insert.

@Override
public Uri insert(Uri url, ContentValues initialValues) {
    long rowID = db.getWritableDatabase().insert(TABLE, Constants.TITLE, initialValues);
    if (rowID > 0) {
        Uri uri = ContentUris.withAppendedId(Provider.Constants.CONTENT_URI, rowID);
        getContext().getContentResolver().notifyChange(uri, null);
        return (uri);
    }
    throw new SQLException("Failed to insert row into " + url);
}
Also used : SQLException(android.database.SQLException) Uri(android.net.Uri)

Example 5 with SQLException

use of android.database.SQLException in project DBFlow by Raizlabs.

the class AndroidDatabaseStatement method executeUpdateDelete.

@Override
public long executeUpdateDelete() {
    long count = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        count = statement.executeUpdateDelete();
    } else {
        statement.execute();
        Cursor cursor = null;
        try {
            cursor = database.rawQuery("SELECT changes() AS affected_row_count", null);
            if (cursor != null && cursor.getCount() > 0 && cursor.moveToFirst()) {
                count = cursor.getLong(cursor.getColumnIndex("affected_row_count"));
            }
        } catch (SQLException e) {
        // Handle exception here.
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    return count;
}
Also used : SQLException(android.database.SQLException) Cursor(android.database.Cursor)

Aggregations

SQLException (android.database.SQLException)306 ContentValues (android.content.ContentValues)143 Cursor (android.database.Cursor)93 Uri (android.net.Uri)78 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)76 ArrayList (java.util.ArrayList)26 SQLiteException (android.database.sqlite.SQLiteException)21 Intent (android.content.Intent)16 SQLiteStatement (android.database.sqlite.SQLiteStatement)14 HandlerThread (android.os.HandlerThread)10 ContentResolver (android.content.ContentResolver)9 IOException (java.io.IOException)9 Context (android.content.Context)8 DatabaseUtils (android.database.DatabaseUtils)8 Gson (com.google.gson.Gson)8 File (java.io.File)8 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)7 RAction (io.github.mthli.Bitocle.Database.Repo.RAction)7 DatabaseObject (com.dailystudio.dataobject.DatabaseObject)6 Repo (io.github.mthli.Bitocle.Database.Repo.Repo)6