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


Java SupportSQLiteStatement类代码示例

本文整理汇总了Java中android.arch.persistence.db.SupportSQLiteStatement的典型用法代码示例。如果您正苦于以下问题:Java SupportSQLiteStatement类的具体用法?Java SupportSQLiteStatement怎么用?Java SupportSQLiteStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SupportSQLiteStatement类属于android.arch.persistence.db包,在下文中一共展示了SupportSQLiteStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的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: build

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@NonNull
@CheckResult
CompiledUpdate build() {
  final String sql = SqlCreator.getSql(sqlTreeRoot, sqlNodeCount);
  final SupportSQLiteStatement stm = dbConnection.compileStatement(sql);
  final ArrayList<String> args = this.args;
  for (int i = args.size(); i != 0; i--) {
    final String arg = args.get(i - 1);
    if (arg != null) {
      stm.bindString(i, arg);
    } else {
      stm.bindNull(i);
    }
  }
  return new CompiledUpdate(stm, tableNode.tableName, dbConnection);
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:17,代码来源:CompiledUpdate.java

示例3: compileStatement

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@NonNull
@CheckResult
SupportSQLiteStatement compileStatement(@OperationHelper.Op int operation,
                                        @NonNull String tableName,
                                        int maxColumns,
                                        @NonNull SimpleArrayMap<String, Object> values,
                                        @NonNull String resolutionColumn,
                                        @NonNull EntityDbManager manager) {
  StringBuilder sqlBuilder = this.sqlBuilder;
  if (sqlBuilder == null) {
    sqlBuilder = new StringBuilder(7 + conflictAlgorithm.length() + maxColumns * 22);
    this.sqlBuilder = sqlBuilder;
  }
  final int lastCompiledOperation = this.lastCompiledOperation;
  this.lastCompiledOperation = operation;

  return compileStatement(
      operation == lastCompiledOperation,
      operation,
      sqlBuilder,
      conflictAlgorithm,
      tableName,
      values,
      resolutionColumn,
      manager);
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:27,代码来源:VariableArgsOperationHelper.java

示例4: bindValue

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
private static void bindValue(@NonNull SupportSQLiteStatement statement, int pos, Object value) {
  if (value instanceof String) {
    statement.bindString(pos, (String) value);
  } else if (value instanceof Number) {
    if (value instanceof Float || value instanceof Double) {
      statement.bindDouble(pos, ((Number) value).doubleValue());
    } else {
      statement.bindLong(pos, ((Number) value).longValue());
    }
  } else if (value instanceof byte[]) {
    statement.bindBlob(pos, (byte[]) value);
  } else if (value instanceof Byte[]) {
    statement.bindBlob(pos, Utils.toByteArray((Byte[]) value));
  } else {
    statement.bindString(pos, value.toString());
  }
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:18,代码来源:VariableArgsOperationHelper.java

示例5: executeInsertAndTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@Test public void executeInsertAndTrigger() {
  SupportSQLiteStatement statement = real.compileStatement("INSERT INTO "
      + TABLE_EMPLOYEE + " (" + NAME + ", " + USERNAME + ") "
      + "VALUES ('Chad Chadson', 'chad')");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();

  db.executeInsert(TABLE_EMPLOYEE, statement);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .hasRow("chad", "Chad Chadson")
      .isExhausted();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:21,代码来源:BriteDatabaseTest.java

示例6: executeInsertAndTriggerNoTables

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@Test public void executeInsertAndTriggerNoTables() {
  SupportSQLiteStatement statement = real.compileStatement("INSERT INTO "
      + TABLE_EMPLOYEE + " (" + NAME + ", " + USERNAME + ") "
      + "VALUES ('Chad Chadson', 'chad')");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();

  db.executeInsert(Collections.<String>emptySet(), statement);

  o.assertNoMoreEvents();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:17,代码来源:BriteDatabaseTest.java

示例7: executeInsertThrowsAndDoesNotTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@Test public void executeInsertThrowsAndDoesNotTrigger() {
  SupportSQLiteStatement statement = real.compileStatement("INSERT INTO "
      + TABLE_EMPLOYEE + " (" + NAME + ", " + USERNAME + ") "
      + "VALUES ('Alice Allison', 'alice')");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeInsert(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:17,代码来源:BriteDatabaseTest.java

示例8: executeInsertWithArgsAndTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@Test public void executeInsertWithArgsAndTrigger() {
  SupportSQLiteStatement statement = real.compileStatement("INSERT INTO "
      + TABLE_EMPLOYEE + " (" + NAME + ", " + USERNAME + ") VALUES (?, ?)");
  statement.bindString(1, "Chad Chadson");
  statement.bindString(2, "chad");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();

  db.executeInsert(TABLE_EMPLOYEE, statement);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .hasRow("chad", "Chad Chadson")
      .isExhausted();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:22,代码来源:BriteDatabaseTest.java

示例9: executeInsertWithArgsThrowsAndDoesNotTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@Test public void executeInsertWithArgsThrowsAndDoesNotTrigger() {
  SupportSQLiteStatement statement = real.compileStatement("INSERT INTO "
      + TABLE_EMPLOYEE + " (" + NAME + ", " + USERNAME + ") VALUES (?, ?)");
  statement.bindString(1, "Alice Aliison");
  statement.bindString(2, "alice");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeInsert(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:18,代码来源:BriteDatabaseTest.java

示例10: executeUpdateDeleteAndTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + NAME + " = 'Zach'");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();

  db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
  o.assertCursor()
      .hasRow("alice", "Zach")
      .hasRow("bob", "Zach")
      .hasRow("eve", "Zach")
      .isExhausted();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:21,代码来源:BriteDatabaseTest.java

示例11: executeUpdateDeleteAndDontTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndDontTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(""
      + "UPDATE " + TABLE_EMPLOYEE
      + " SET " + NAME + " = 'Zach'"
      + " WHERE " + NAME + " = 'Rob'");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();

  db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
  o.assertNoMoreEvents();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:19,代码来源:BriteDatabaseTest.java

示例12: executeUpdateDeleteAndTriggerWithNoTables

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTriggerWithNoTables() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + NAME + " = 'Zach'");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();

  db.executeUpdateDelete(Collections.<String>emptySet(), statement);

  o.assertNoMoreEvents();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:18,代码来源:BriteDatabaseTest.java

示例13: executeUpdateDeleteThrowsAndDoesNotTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteThrowsAndDoesNotTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + USERNAME + " = 'alice'");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:18,代码来源:BriteDatabaseTest.java

示例14: executeUpdateDeleteWithArgsAndTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteWithArgsAndTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + NAME + " = ?");
  statement.bindString(1, "Zach");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();

  db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
  o.assertCursor()
      .hasRow("alice", "Zach")
      .hasRow("bob", "Zach")
      .hasRow("eve", "Zach")
      .isExhausted();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:22,代码来源:BriteDatabaseTest.java

示例15: executeUpdateDeleteWithArgsThrowsAndDoesNotTrigger

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteWithArgsThrowsAndDoesNotTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + USERNAME + " = ?");
  statement.bindString(1, "alice");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:19,代码来源:BriteDatabaseTest.java


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