Search in sources :

Example 16 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 17 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 18 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 19 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 20 with SQLException

use of android.database.SQLException in project android-app by eoecn.

the class APNManager method addNewApn.

/**
	 * 增加新的apn
	 * 
	 * @param apnNode
	 * @return
	 */
private int addNewApn(APN apnNode) {
    int apnId = -1;
    ContentValues values = new ContentValues();
    values.put("name", apnNode.getName());
    values.put("apn", apnNode.getApn());
    values.put("proxy", apnNode.getProxy());
    values.put("port", apnNode.getPort());
    values.put("user", apnNode.getUser());
    values.put("password", apnNode.getPassword());
    values.put("mcc", apnNode.getMcc());
    values.put("mnc", apnNode.getMnc());
    values.put("numeric", apnNode.getNumeric());
    // Note: this values need to be update, and for now, it only for XT800.
    Cursor c = null;
    try {
        Uri newRow = resolver.insert(APN_TABLE_URI, values);
        if (newRow != null) {
            c = resolver.query(newRow, null, null, null, null);
            int idindex = c.getColumnIndex("_id");
            c.moveToFirst();
            apnId = c.getShort(idindex);
            Log.d("Robert", "New ID: " + apnId + ": Inserting new APN succeeded!");
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    if (c != null)
        c.close();
    return apnId;
}
Also used : ContentValues(android.content.ContentValues) SQLException(android.database.SQLException) Cursor(android.database.Cursor) Uri(android.net.Uri)

Aggregations

SQLException (android.database.SQLException)224 ContentValues (android.content.ContentValues)114 Uri (android.net.Uri)60 Cursor (android.database.Cursor)57 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)39 SQLiteException (android.database.sqlite.SQLiteException)18 Intent (android.content.Intent)16 ArrayList (java.util.ArrayList)14 SQLiteStatement (android.database.sqlite.SQLiteStatement)13 HandlerThread (android.os.HandlerThread)10 DatabaseUtils (android.database.DatabaseUtils)8 Gson (com.google.gson.Gson)8 RAction (io.github.mthli.Bitocle.Database.Repo.RAction)7 Repo (io.github.mthli.Bitocle.Database.Repo.Repo)6 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)5 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)5 IOException (java.io.IOException)5 BAction (io.github.mthli.Bitocle.Database.Bookmark.BAction)4 Test (org.junit.Test)4 Activity (android.app.Activity)3