• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SupportSQLiteStatement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: delete

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


示例17: update

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


示例18: CompiledDelete

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
CompiledDelete(@NonNull SupportSQLiteStatement deleteStm,
               @NonNull String tableName,
               @NonNull DbConnectionImpl dbConnection) {
  this.deleteStm = deleteStm;
  this.tableName = tableName;
  this.dbConnection = dbConnection;
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:8,代码来源:CompiledDelete.java


示例19: build

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
@NonNull
@CheckResult
CompiledDelete build() {
  final String sql = SqlCreator.getSql(sqlTreeRoot, sqlNodeCount);
  final SupportSQLiteStatement stm = dbConnection.compileStatement(sql);
  bindAllArgsAsStrings(stm, args.toArray(new String[args.size()]));
  return new CompiledDelete(stm, from.tableName, dbConnection);
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:9,代码来源:CompiledDelete.java


示例20: CompiledUpdate

import android.arch.persistence.db.SupportSQLiteStatement; //导入依赖的package包/类
CompiledUpdate(@NonNull SupportSQLiteStatement updateStm,
               @NonNull String tableName,
               @NonNull DbConnectionImpl dbConnection) {
  this.updateStm = updateStm;
  this.tableName = tableName;
  this.dbConnection = dbConnection;
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:8,代码来源:CompiledUpdate.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java B2CConverter类代码示例发布时间:2022-05-23
下一篇:
Java Projection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap