本文整理汇总了Java中android.arch.persistence.db.SimpleSQLiteQuery.bind方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleSQLiteQuery.bind方法的具体用法?Java SimpleSQLiteQuery.bind怎么用?Java SimpleSQLiteQuery.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.arch.persistence.db.SimpleSQLiteQuery
的用法示例。
在下文中一共展示了SimpleSQLiteQuery.bind方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import android.arch.persistence.db.SimpleSQLiteQuery; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("ThrowFromFinallyBlock")
@Override
public int delete(String table, String whereClause, Object[] whereArgs) {
String query = "DELETE FROM " + table
+ (isEmpty(whereClause) ? "" : " WHERE " + whereClause);
SupportSQLiteStatement statement = compileStatement(query);
try {
SimpleSQLiteQuery.bind(statement, whereArgs);
return statement.executeUpdateDelete();
}
finally {
try {
statement.close();
}
catch (Exception e) {
throw new RuntimeException("Exception attempting to close statement", e);
}
}
// return(safeDb.delete(table, whereClause, stringify(whereArgs)));
}
示例2: delete
import android.arch.persistence.db.SimpleSQLiteQuery; //导入方法依赖的package包/类
@Override
public int delete(String table, String whereClause, Object[] whereArgs) {
String query = "DELETE FROM " + table
+ (isEmpty(whereClause) ? "" : " WHERE " + whereClause);
SupportSQLiteStatement statement = compileStatement(query);
SimpleSQLiteQuery.bind(statement, whereArgs);
return statement.executeUpdateDelete();
}
示例3: update
import android.arch.persistence.db.SimpleSQLiteQuery; //导入方法依赖的package包/类
@Override
public int update(String table, int conflictAlgorithm, ContentValues values, String whereClause,
Object[] whereArgs) {
// taken from SQLiteDatabase class.
if (values == null || values.size() == 0) {
throw new IllegalArgumentException("Empty values");
}
StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE ");
sql.append(CONFLICT_VALUES[conflictAlgorithm]);
sql.append(table);
sql.append(" SET ");
// move all bind args to one array
int setValuesSize = values.size();
int bindArgsSize = (whereArgs == null) ? setValuesSize : (setValuesSize + whereArgs.length);
Object[] bindArgs = new Object[bindArgsSize];
int i = 0;
for (String colName : values.keySet()) {
sql.append((i > 0) ? "," : "");
sql.append(colName);
bindArgs[i++] = values.get(colName);
sql.append("=?");
}
if (whereArgs != null) {
for (i = setValuesSize; i < bindArgsSize; i++) {
bindArgs[i] = whereArgs[i - setValuesSize];
}
}
if (!isEmpty(whereClause)) {
sql.append(" WHERE ");
sql.append(whereClause);
}
SupportSQLiteStatement stmt = compileStatement(sql.toString());
SimpleSQLiteQuery.bind(stmt, bindArgs);
return stmt.executeUpdateDelete();
}
示例4: delete
import android.arch.persistence.db.SimpleSQLiteQuery; //导入方法依赖的package包/类
@Override
//we shouldn't worry about AutoClosable nor try-with-resources - they are working fine on API lower than 19
@SuppressLint("NewApi")
public int delete(String table, String whereClause, Object[] whereArgs) {
String query = "DELETE FROM " + table
+ (isEmpty(whereClause) ? "" : " WHERE " + whereClause);
try {
try (SupportSQLiteStatement statement = compileStatement(query)) {
SimpleSQLiteQuery.bind(statement, whereArgs);
return statement.executeUpdateDelete();
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例5: update
import android.arch.persistence.db.SimpleSQLiteQuery; //导入方法依赖的package包/类
@Override
public int update(String table, int conflictAlgorithm, ContentValues values, String whereClause,
Object[] whereArgs) {
// taken from SQLiteDatabase class.
if (values == null || values.size() == 0) {
throw new IllegalArgumentException("Empty values");
}
StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE ");
sql.append(CONFLICT_VALUES[conflictAlgorithm]);
sql.append(table);
sql.append(" SET ");
// move all bind args to one array
int setValuesSize = values.size();
int bindArgsSize = (whereArgs == null) ? setValuesSize : (setValuesSize + whereArgs.length);
Object[] bindArgs = new Object[bindArgsSize];
int i = 0;
for (String colName : values.keySet()) {
sql.append((i > 0) ? "," : "");
sql.append(colName);
bindArgs[i++] = values.get(colName);
sql.append("=?");
}
if (whereArgs != null) {
for (i = setValuesSize; i < bindArgsSize; i++) {
bindArgs[i] = whereArgs[i - setValuesSize];
}
}
if (!isEmpty(whereClause)) {
sql.append(" WHERE ");
sql.append(whereClause);
}
SupportSQLiteStatement stmt = compileStatement(sql.toString());
SimpleSQLiteQuery.bind(stmt, bindArgs);
return stmt.executeUpdateDelete();
}
示例6: update
import android.arch.persistence.db.SimpleSQLiteQuery; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int update(String table, int conflictAlgorithm, ContentValues values,
String whereClause, Object[] whereArgs) {
// taken from SQLiteDatabase class.
if (values == null || values.size() == 0) {
throw new IllegalArgumentException("Empty values");
}
StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE ");
sql.append(CONFLICT_VALUES[conflictAlgorithm]);
sql.append(table);
sql.append(" SET ");
// move all bind args to one array
int setValuesSize = values.size();
int bindArgsSize = (whereArgs == null) ? setValuesSize : (setValuesSize + whereArgs.length);
Object[] bindArgs = new Object[bindArgsSize];
int i = 0;
for (String colName : values.keySet()) {
sql.append((i > 0) ? "," : "");
sql.append(colName);
bindArgs[i++] = values.get(colName);
sql.append("=?");
}
if (whereArgs != null) {
for (i = setValuesSize; i < bindArgsSize; i++) {
bindArgs[i] = whereArgs[i - setValuesSize];
}
}
if (!isEmpty(whereClause)) {
sql.append(" WHERE ");
sql.append(whereClause);
}
SupportSQLiteStatement statement = compileStatement(sql.toString());
try {
SimpleSQLiteQuery.bind(statement, bindArgs);
return statement.executeUpdateDelete();
}
finally {
try {
statement.close();
}
catch (Exception e) {
throw new RuntimeException("Exception attempting to close statement", e);
}
}
}