當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteStatement.executeUpdateDelete方法代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteStatement.executeUpdateDelete方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteStatement.executeUpdateDelete方法的具體用法?Java SQLiteStatement.executeUpdateDelete怎麽用?Java SQLiteStatement.executeUpdateDelete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.sqlite.SQLiteStatement的用法示例。


在下文中一共展示了SQLiteStatement.executeUpdateDelete方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: executeUpdateDelete

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
public int executeUpdateDelete(SqlInfo sqlInfo) throws DbException {
    SQLiteStatement statement = null;
    try {
        statement = sqlInfo.buildStatement(database);
        return statement.executeUpdateDelete();
    } catch (Throwable e) {
        throw new DbException(e);
    } finally {
        if (statement != null) {
            try {
                statement.releaseReference();
            } catch (Throwable ex) {
                LogUtil.e(ex.getMessage(), ex);
            }
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:DbManagerImpl.java

示例2: del

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
public int del(Condition query) throws DBException
{
    SQLiteStatement statement = null;
    try
    {
        SqlUtil.WhereSQL whereSQL = SqlUtil.toDelete(tableName, checkCondition(query), true);

        statement = db.compileStatement(whereSQL.sql);
        Object[] args = whereSQL.args;
        for (int i = 0; i < args.length; i++)
        {
            bind(i + 1, args[i], statement);
        }

        return statement.executeUpdateDelete();
    } catch (Exception e)
    {
        throw new DBException(e);
    } finally
    {
        close(statement);
    }

}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:26,代碼來源:SqliteHandle.java

示例3: update

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public int update(Uri uri, ContentValues values, String selection,
		String[] selectionArgs) {
	int updateCount = 0;

	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();

	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.get(3);

	String updateView = "update views set query = ?, date_synced = ? where record_id = ? and name = ?";
       SQLiteStatement updateViewStmt = sqlDb.compileStatement(updateView);

	updateViewStmt.bindString(1, values.getAsString("query"));
	updateViewStmt.bindString(2, values.getAsString("date_synced"));
	updateViewStmt.bindString(3, recordId);
	updateViewStmt.bindString(4, name);
	
	updateCount = updateViewStmt.executeUpdateDelete();

	if (updateCount > 0) { 
	      getContext().getContentResolver().notifyChange(uri, null); 
	} 

	return updateCount; 
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:27,代碼來源:ViewProvider.java

示例4: convertShortcutsToLauncherActivities

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
/**
 * Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
 * launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
 */
@Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
    db.beginTransaction();
    Cursor c = null;
    SQLiteStatement updateStmt = null;

    try {
        // Only consider the primary user as other users can't have a shortcut.
        long userSerial = getDefaultUserSerial();
        c = db.query(Favorites.TABLE_NAME, new String[] {
                Favorites._ID,
                Favorites.INTENT,
            }, "itemType=" + Favorites.ITEM_TYPE_SHORTCUT + " AND profileId=" + userSerial,
            null, null, null, null);

        updateStmt = db.compileStatement("UPDATE favorites SET itemType="
                + Favorites.ITEM_TYPE_APPLICATION + " WHERE _id=?");

        final int idIndex = c.getColumnIndexOrThrow(Favorites._ID);
        final int intentIndex = c.getColumnIndexOrThrow(Favorites.INTENT);

        while (c.moveToNext()) {
            String intentDescription = c.getString(intentIndex);
            Intent intent;
            try {
                intent = Intent.parseUri(intentDescription, 0);
            } catch (URISyntaxException e) {
                e.printStackTrace();
                continue;
            }

            if (!Utilities.isLauncherAppTarget(intent)) {
                continue;
            }

            long id = c.getLong(idIndex);
            updateStmt.bindLong(1, id);
            updateStmt.executeUpdateDelete();
        }
        db.setTransactionSuccessful();
    } catch (SQLException ex) {
        ex.printStackTrace();
    } finally {
        db.endTransaction();
        if (c != null) {
            c.close();
        }
        if (updateStmt != null) {
            updateStmt.close();
        }
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:56,代碼來源:LauncherProvider.java

示例5: update

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
public int update(Condition query, NameValues nameValues) throws DBException
{
    if (nameValues == null || nameValues.size() == 0)
    {
        return 0;
    }
    int n = 0;
    SQLiteStatement statement = null;
    try
    {
        SqlUtil.WhereSQL whereSql = SqlUtil
                .toSetValues(tableName, nameValues.names(), checkCondition(query), false);
        statement = db.compileStatement(whereSql.sql);
        for (int i = 0; i < nameValues.size(); i++)
        {
            bind(i + 1, nameValues.value(i), statement);
        }
        Object[] args = whereSql.args;
        for (int i = 0, k = nameValues.size() + 1; i < args.length; i++, k++)
        {
            bind(k, args[i], statement);
        }
        n = statement.executeUpdateDelete();

    } catch (Exception e)
    {
        throw new DBException(e);
    } finally
    {
        close(statement);
    }

    return n;
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:36,代碼來源:SqliteHandle.java

示例6: execSQLStr

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public int execSQLStr(String sqlStr) {
    if (!isDBOk()) {
        return Constant.FAIL;
    }

    SQLiteStatement statement = _db.compileStatement(sqlStr);

    try {
        return statement.executeUpdateDelete();
    } finally {
        statement.close();
    }
}
 
開發者ID:WeiMei-Tian,項目名稱:editor-sql,代碼行數:14,代碼來源:SQLHelper.java

示例7: executeDeleteQuery

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static int executeDeleteQuery(SQLiteStatement sqLiteStatement, long[] ids, int numIds) {
    sqLiteStatement.clearBindings();
    for (int i = 0; i < numIds; i++) {
        sqLiteStatement.bindLong(i + 1, ids[i]);
    }
    return sqLiteStatement.executeUpdateDelete();
}
 
開發者ID:hortonworks,項目名稱:nifi-android-s2s,代碼行數:8,代碼來源:SQLiteDataPacketQueue.java

示例8: executeUpdateDelete

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@TargetApi(DatabaseConstants.MIN_API_LEVEL)
private <T> T executeUpdateDelete(
        SQLiteDatabase database,
        String query,
        ExecuteResultHandler<T> handler) {
    SQLiteStatement statement = database.compileStatement(query);
    int count = statement.executeUpdateDelete();
    return handler.handleUpdateDelete(count);
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:10,代碼來源:RongDatabaseDriver.java

示例9: update

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public int update() {

        try {
            SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("UPDATE compra_itens SET" +
                    " dt_compra = " + String.valueOf(getDtCompra()) +
                    ", dt_compra_inv = " + String.valueOf(getDtCompraInv()) +
                    " WHERE id_compra = " + String.valueOf(getIdCompra()));

            sStatement.executeUpdateDelete();

            return Funcoes.mDataBase.update(mTable, getValues(), "id_compra = ?", new String[]{String.valueOf(getIdCompra())});
        } catch (Exception e) {
            return -1;
        }
    }
 
開發者ID:marcelohanel,項目名稱:Cash,代碼行數:16,代碼來源:tblCompras.java

示例10: update

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public int update() {

        try {
            SQLiteStatement sStatement = Funcoes.mDataBase.compileStatement("UPDATE venda_itens SET" +
                    " dt_venda = " + String.valueOf(getDtVenda()) +
                    ", dt_venda_inv = " + String.valueOf(getDtVendaInv()) +
                    " WHERE id_venda = " + String.valueOf(getIdVenda()));

            sStatement.executeUpdateDelete();

            return Funcoes.mDataBase.update(mTable, getValues(), "id_venda = ?", new String[]{String.valueOf(getIdVenda())});
        } catch (Exception e) {
            return -1;
        }
    }
 
開發者ID:marcelohanel,項目名稱:Cash,代碼行數:16,代碼來源:tblVendas.java

示例11: convertShortcutsToLauncherActivities

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
/**
 * Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
 * launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
 */
@Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
    db.beginTransaction();
    Cursor c = null;
    SQLiteStatement updateStmt = null;

    try {
        // Only consider the primary user as other users can't have a shortcut.
        long userSerial = getDefaultUserSerial();
        c = db.query(Favorites.TABLE_NAME, new String[] {
                Favorites._ID,
                Favorites.INTENT,
            }, "itemType=" + Favorites.ITEM_TYPE_SHORTCUT + " AND profileId=" + userSerial,
            null, null, null, null);

        updateStmt = db.compileStatement("UPDATE favorites SET itemType="
                + Favorites.ITEM_TYPE_APPLICATION + " WHERE _id=?");

        final int idIndex = c.getColumnIndexOrThrow(Favorites._ID);
        final int intentIndex = c.getColumnIndexOrThrow(Favorites.INTENT);

        while (c.moveToNext()) {
            String intentDescription = c.getString(intentIndex);
            Intent intent;
            try {
                intent = Intent.parseUri(intentDescription, 0);
            } catch (URISyntaxException e) {
                Log.e(TAG, "Unable to parse intent", e);
                continue;
            }

            if (!Utilities.isLauncherAppTarget(intent)) {
                continue;
            }

            long id = c.getLong(idIndex);
            updateStmt.bindLong(1, id);
            updateStmt.executeUpdateDelete();
        }
        db.setTransactionSuccessful();
    } catch (SQLException ex) {
        Log.w(TAG, "Error deduping shortcuts", ex);
    } finally {
        db.endTransaction();
        if (c != null) {
            c.close();
        }
        if (updateStmt != null) {
            updateStmt.close();
        }
    }
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:56,代碼來源:LauncherProvider.java

示例12: delete

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public int delete(Uri uri, String selection, String[] selectionArgs) {
	// TODO: Delete things not shared with other views
	
	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();

	List<String> segments = uri.getPathSegments();

	String recordId = segments.get(1);
	String name = segments.get(3);

	String deleteView = "delete from view_things where record_id = ? and view_name = ?";
       SQLiteStatement deleteViewStmt = sqlDb.compileStatement(deleteView);

	deleteViewStmt.bindString(1, recordId);
	deleteViewStmt.bindString(2, name);
	
	int rc = deleteViewStmt.executeUpdateDelete();
	
	getContext()
               .getContentResolver()
               .notifyChange(uri, null);

	return rc;
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:25,代碼來源:ViewThingsProvider.java

示例13: delete

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public int delete(Uri uri, String selection, String[] selectionArgs) {
	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();

	List<String> segments = uri.getPathSegments();
	String thingId = segments.get(1);

	String deleteThing = "delete from things where thing_id = ?";
       SQLiteStatement deleteThingStmt = sqlDb.compileStatement(deleteThing);

	deleteThingStmt.bindString(1, thingId);
	
	int rc = deleteThingStmt.executeUpdateDelete();
	
	getContext()
               .getContentResolver()
               .notifyChange(uri, null);
    
	return rc;
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:20,代碼來源:ThingProvider.java

示例14: delete

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public int delete(Uri uri, String selection, String[] selectionArgs) {
	// TODO: Delete things not shared with other views
	
	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();

	List<String> segments = uri.getPathSegments();

	String recordId = segments.get(1);
	String name = segments.get(3);

	String deleteView = "delete from views where record_id = ? and name = ?";
       SQLiteStatement deleteViewStmt = sqlDb.compileStatement(deleteView);

	deleteViewStmt.bindString(1, recordId);
	deleteViewStmt.bindString(2, name);
	
	int rc = deleteViewStmt.executeUpdateDelete();
	
	getContext()
               .getContentResolver()
               .notifyChange(uri, null);

	return rc;
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:25,代碼來源:ViewProvider.java


注:本文中的android.database.sqlite.SQLiteStatement.executeUpdateDelete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。