当前位置: 首页>>代码示例>>Java>>正文


Java SimpleSQLiteQuery.bind方法代码示例

本文整理汇总了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)));
  }
 
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:26,代码来源:Database.java

示例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();
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:9,代码来源:FrameworkSQLiteDatabase.java

示例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();
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:38,代码来源:FrameworkSQLiteDatabase.java

示例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);
    }
}
 
开发者ID:SelvinPL,项目名称:SyncFrameworkAndroid,代码行数:16,代码来源:SqlCipherDatabase.java

示例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();
}
 
开发者ID:SelvinPL,项目名称:SyncFrameworkAndroid,代码行数:38,代码来源:SqlCipherDatabase.java

示例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);
    }
  }
}
 
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:52,代码来源:Database.java


注:本文中的android.arch.persistence.db.SimpleSQLiteQuery.bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。