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


Java SimpleSQLiteQuery类代码示例

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


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

import android.arch.persistence.db.SimpleSQLiteQuery; //导入依赖的package包/类
@Test public void queryWithQueryObject() {
  db.createQuery(TABLE_EMPLOYEE, new SimpleSQLiteQuery(SELECT_EMPLOYEES)).subscribe(o);
  o.assertCursor()
      .hasRow("alice", "Alice Allison")
      .hasRow("bob", "Bob Bobberson")
      .hasRow("eve", "Eve Evenson")
      .isExhausted();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:9,代码来源:BriteDatabaseTest.java

示例5: 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

示例6: 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

示例7: query

import android.arch.persistence.db.SimpleSQLiteQuery; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Cursor query(String sql) {
  return(query(new SimpleSQLiteQuery(sql)));
}
 
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:8,代码来源:Database.java

示例8: 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

示例9: queryMultipleTablesWithQueryObject

import android.arch.persistence.db.SimpleSQLiteQuery; //导入依赖的package包/类
@Test public void queryMultipleTablesWithQueryObject() {
  db.createQuery(BOTH_TABLES, new SimpleSQLiteQuery(SELECT_MANAGER_LIST)).subscribe(o);
  o.assertCursor()
      .hasRow("Eve Evenson", "Alice Allison")
      .isExhausted();
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:7,代码来源:BriteDatabaseTest.java

示例10: createQuery

import android.arch.persistence.db.SimpleSQLiteQuery; //导入依赖的package包/类
/**
 * Create an observable which will notify subscribers with a {@linkplain Query query} for
 * execution. Subscribers are responsible for <b>always</b> closing {@link Cursor} instance
 * returned from the {@link Query}.
 * <p>
 * Subscribers will receive an immediate notification for initial data as well as subsequent
 * notifications for when the supplied {@code table}'s data changes through the {@code insert},
 * {@code update}, and {@code delete} methods of this class. Unsubscribe when you no longer want
 * updates to a query.
 * <p>
 * Since database triggers are inherently asynchronous, items emitted from the returned
 * observable use the {@link Scheduler} supplied to {@link SqlBrite#wrapDatabaseHelper}. For
 * consistency, the immediate notification sent on subscribe also uses this scheduler. As such,
 * calling {@link Observable#subscribeOn subscribeOn} on the returned observable has no effect.
 * <p>
 * Note: To skip the immediate notification and only receive subsequent notifications when data
 * has changed call {@code skip(1)} on the returned observable.
 * <p>
 * <b>Warning:</b> this method does not perform the query! Only by subscribing to the returned
 * {@link Observable} will the operation occur.
 *
 * @see SupportSQLiteDatabase#query(String, Object[])
 */
@CheckResult @NonNull
public QueryObservable createQuery(@NonNull final String table, @NonNull String sql,
    @NonNull Object... args) {
  return createQuery(new DatabaseQuery(singletonList(table), new SimpleSQLiteQuery(sql, args)));
}
 
开发者ID:square,项目名称:sqlbrite,代码行数:29,代码来源:BriteDatabase.java


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