當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteStatement類代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteStatement的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteStatement類的具體用法?Java SQLiteStatement怎麽用?Java SQLiteStatement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SQLiteStatement類屬於android.database.sqlite包,在下文中一共展示了SQLiteStatement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindValues

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, UserEntity entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
    stmt.bindLong(2, entity.getPeerId());
    stmt.bindLong(3, entity.getGender());
    stmt.bindString(4, entity.getMainName());
    stmt.bindString(5, entity.getPinyinName());
    stmt.bindString(6, entity.getRealName());
    stmt.bindString(7, entity.getAvatar());
    stmt.bindString(8, entity.getPhone());
    stmt.bindString(9, entity.getEmail());
    stmt.bindLong(10, entity.getDepartmentId());
    stmt.bindLong(11, entity.getStatus());
    stmt.bindLong(12, entity.getCreated());
    stmt.bindLong(13, entity.getUpdated());
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:23,代碼來源:UserDao.java

示例2: executeInsertWithArgsThrowsAndDoesNotTrigger

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@Test public void executeInsertWithArgsThrowsAndDoesNotTrigger() {
  SQLiteStatement 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:jiechic,項目名稱:sqlbrite-sqlcipher,代碼行數:18,代碼來源:BriteDatabaseTest.java

示例3: insert

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
public Uri insert(Uri uri, ContentValues values) {
	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();
	
	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.get(3);

       String insertView = "Insert or replace into views (record_id, name, query, date_synced) values(?,?,?,?)";

       SQLiteStatement insertViewStmt = sqlDb.compileStatement(insertView);

       insertViewStmt.bindString(1, recordId);
       insertViewStmt.bindString(2, name);
       insertViewStmt.bindString(3, values.getAsString("query"));
       insertViewStmt.bindString(4, values.getAsString("date_synced"));
       insertViewStmt.execute();
       
       getContext()
               .getContentResolver()
               .notifyChange(uri, null);
      
       return uri;
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:24,代碼來源:ViewProvider.java

示例4: executeUpdateDelete

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@Override
public int executeUpdateDelete(SqlInfo sqlInfo) throws DbException {
    SQLiteStatement statement = null;
    try {
        statement = sqlInfo.buildStatement(database);
        return statement.executeUpdateDelete();
    } catch (Throwable e) {
        throw new DbException(e);
    } finally {
        if (statement != null) {
            try {
                statement.releaseReference();
            } catch (Throwable ex) {
                LogUtil.e(ex.getMessage(), ex);
            }
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:DbManagerImpl.java

示例5: bindValues

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, Bpm entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String mBpm = entity.getMBpm();
    if (mBpm != null) {
        stmt.bindString(2, mBpm);
    }
 
    String mTime = entity.getMTime();
    if (mTime != null) {
        stmt.bindString(3, mTime);
    }
 
    String mDescription = entity.getMDescription();
    if (mDescription != null) {
        stmt.bindString(4, mDescription);
    }
}
 
開發者ID:InnoFang,項目名稱:FamilyBond,代碼行數:25,代碼來源:BpmDao.java

示例6: bindValues

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, ToManyTargetEntity entity) {
    stmt.clearBindings();
 
    Long toManyId = entity.getToManyId();
    if (toManyId != null) {
        stmt.bindLong(1, toManyId);
    }
 
    Long toManyIdDesc = entity.getToManyIdDesc();
    if (toManyIdDesc != null) {
        stmt.bindLong(2, toManyIdDesc);
    }
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(3, id);
    }
 
    String targetJoinProperty = entity.getTargetJoinProperty();
    if (targetJoinProperty != null) {
        stmt.bindString(4, targetJoinProperty);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:ToManyTargetEntityDao.java

示例7: executeUpdateDeleteThrowsAndDoesNotTrigger

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteThrowsAndDoesNotTrigger() {
  SQLiteStatement 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:jiechic,項目名稱:sqlbrite-sqlcipher,代碼行數:18,代碼來源:BriteDatabaseTest.java

示例8: executeUpdateDeleteAndTriggerWithNoTables

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTriggerWithNoTables() {
  SQLiteStatement 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:jiechic,項目名稱:sqlbrite-sqlcipher,代碼行數:18,代碼來源:BriteDatabaseTest.java

示例9: bindValues

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, User entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String phone = entity.getPhone();
    if (phone != null) {
        stmt.bindString(2, phone);
    }
 
    String psw = entity.getPsw();
    if (psw != null) {
        stmt.bindString(3, psw);
    }
}
 
開發者ID:guxiaonian,項目名稱:MeiLa_GNN,代碼行數:20,代碼來源:UserDao.java

示例10: bindValues

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, SessionEntity entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
    stmt.bindString(2, entity.getSessionKey());
    stmt.bindLong(3, entity.getPeerId());
    stmt.bindLong(4, entity.getPeerType());
    stmt.bindLong(5, entity.getLatestMsgType());
    stmt.bindLong(6, entity.getLatestMsgId());
    stmt.bindString(7, entity.getLatestMsgData());
    stmt.bindLong(8, entity.getTalkId());
    stmt.bindLong(9, entity.getCreated());
    stmt.bindLong(10, entity.getUpdated());
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:20,代碼來源:SessionDao.java

示例11: createInsertStatement

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
SQLiteStatement createInsertStatement(SQLiteDatabase database) {
  return database.compileStatement("INSERT INTO " + TABLE_NAME + " (" + ADDRESS + ", " +
                                                                    PERSON + ", " +
                                                                    DATE_SENT + ", " +
                                                                    DATE_RECEIVED  + ", " +
                                                                    PROTOCOL + ", " +
                                                                    READ + ", " +
                                                                    STATUS + ", " +
                                                                    TYPE + ", " +
                                                                    REPLY_PATH_PRESENT + ", " +
                                                                    SUBJECT + ", " +
                                                                    BODY + ", " +
                                                                    SERVICE_CENTER +
                                                                    ", " + THREAD_ID + ") " +
                                   " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:17,代碼來源:SmsDatabase.java

示例12: bindValues

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, County entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String countyName = entity.getCountyName();
    if (countyName != null) {
        stmt.bindString(2, countyName);
    }
 
    String weatherId = entity.getWeatherId();
    if (weatherId != null) {
        stmt.bindString(3, weatherId);
    }
    stmt.bindLong(4, entity.getCityId());
}
 
開發者ID:weixianshishen,項目名稱:LookWeather,代碼行數:21,代碼來源:CountyDao.java

示例13: executeInsertThrowsAndDoesNotTrigger

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
@Test public void executeInsertThrowsAndDoesNotTrigger() {
  SQLiteStatement 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:jiechic,項目名稱:sqlbrite-sqlcipher,代碼行數:17,代碼來源:BriteDatabaseTest.java

示例14: createItem

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
public int createItem(int list_id, String label)
{
    Log.v(L.TAG, "DataManager.createItem(): Insert item " + label);

    SQLiteDatabase db = helper.getWritableDatabase();
    SQLiteStatement stmt = db.compileStatement("insert into items (list_id,label,active) values (?,?,?)");        
    stmt.bindLong(1, list_id);
    stmt.bindString(2, label);
    stmt.bindLong(3, 1);
    long id = stmt.executeInsert();
    stmt.close();
    db.close();
    
    Log.d(L.TAG, "DataManager.createItem(): Inserted item and got id " + id);
    if(id == -1)
    {
        Log.e(L.TAG, "DataManager.createItem(): Attempt to insert item failed. Got " + id + " from executeInsert()");
    }
    return (int)id;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:21,代碼來源:DataManager.java

示例15: bind

import android.database.sqlite.SQLiteStatement; //導入依賴的package包/類
private void bind(int index, Object value, SQLiteStatement sQLiteStatement)
{
    if (value == null)
    {
        sQLiteStatement.bindNull(index);
    } else
    {
        int i = Arrays.binarySearch(TYPES_ADD, TypeUtil.Type.forSearch(value.getClass()));
        if (i >= 0)
        {
            TypeUtil.Type<TypeUtil.StatementObj> type = TYPES_MULTI_ADD[i];
            type.put(null, value, new TypeUtil.StatementObj(index, sQLiteStatement));
        } else
        {
            throw new DBException("unknown type of " + value.getClass() + " for sqlite");
        }

    }
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:20,代碼來源:SqliteHandle.java


注:本文中的android.database.sqlite.SQLiteStatement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。