本文整理匯總了Java中android.database.sqlite.SQLiteStatement.bindDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteStatement.bindDouble方法的具體用法?Java SQLiteStatement.bindDouble怎麽用?Java SQLiteStatement.bindDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.sqlite.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.bindDouble方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, UsedProduct entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindDouble(2, entity.getQuantity());
stmt.bindLong(3, entity.getUnit() ? 1L: 0L);
stmt.bindLong(4, entity.getIsPurchased() ? 1L: 0L);
stmt.bindLong(5, entity.getDate());
Long productId = entity.getProductId();
if (productId != null) {
stmt.bindLong(6, productId);
}
stmt.bindLong(7, entity.getShoppingListId());
}
示例2: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, SMS entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String time = entity.getTime();
if (time != null) {
stmt.bindString(2, time);
}
String address = entity.getAddress();
if (address != null) {
stmt.bindString(3, address);
}
String content = entity.getContent();
if (content != null) {
stmt.bindString(4, content);
}
stmt.bindDouble(5, entity.getProbability());
}
示例3: buildStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public SQLiteStatement buildStatement(SQLiteDatabase database) {
SQLiteStatement result = database.compileStatement(sql);
if (bindArgs != null) {
for (int i = 1; i < bindArgs.size() + 1; i++) {
KeyValue kv = bindArgs.get(i - 1);
Object value = ColumnUtils.convert2DbValueIfNeeded(kv.value);
if (value == null) {
result.bindNull(i);
} else {
ColumnConverter converter = ColumnConverterFactory.getColumnConverter(value.getClass());
ColumnDbType type = converter.getColumnDbType();
switch (type) {
case INTEGER:
result.bindLong(i, ((Number) value).longValue());
break;
case REAL:
result.bindDouble(i, ((Number) value).doubleValue());
break;
case TEXT:
result.bindString(i, value.toString());
break;
case BLOB:
result.bindBlob(i, (byte[]) value);
break;
default:
result.bindNull(i);
break;
} // end switch
}
}
}
return result;
}
示例4: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, SimpleEntityNotNull entity) {
stmt.clearBindings();
stmt.bindLong(1, entity.getId());
stmt.bindLong(2, entity.getSimpleBoolean() ? 1L: 0L);
stmt.bindLong(3, entity.getSimpleByte());
stmt.bindLong(4, entity.getSimpleShort());
stmt.bindLong(5, entity.getSimpleInt());
stmt.bindLong(6, entity.getSimpleLong());
stmt.bindDouble(7, entity.getSimpleFloat());
stmt.bindDouble(8, entity.getSimpleDouble());
stmt.bindString(9, entity.getSimpleString());
stmt.bindBlob(10, entity.getSimpleByteArray());
}
示例5: updateLocation
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateLocation(LocationModel locationModel) {
SQLiteDatabase db = this.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement(Constants.UPDATE_TABLE_LOCATION);
stmt.bindString(1, locationModel.getName());
stmt.bindDouble(2, locationModel.getLongitude());
stmt.bindDouble(3, locationModel.getLatitude());
stmt.bindString(4, locationModel.getAddress());
stmt.bindString(5, locationModel.getDescription());
stmt.bindLong(6, locationModel.getId());
stmt.execute();
}
示例6: saveDaily
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void saveDaily(List<DailyPvDatum> dailyPvData) {
SQLiteDatabase db = pvDataHelper.getWritableDatabase();
db.beginTransaction();
String sql = "REPLACE INTO " + PvDataContract.DailyPvData.TABLE_NAME +
"(" + PvDataContract.DailyPvData.COLUMN_NAME_YEAR +
"," + PvDataContract.DailyPvData.COLUMN_NAME_MONTH +
"," + PvDataContract.DailyPvData.COLUMN_NAME_DAY +
"," + PvDataContract.DailyPvData.COLUMN_NAME_ENERGY_GENERATED +
"," + PvDataContract.DailyPvData.COLUMN_NAME_PEAK_POWER +
"," + PvDataContract.DailyPvData.COLUMN_NAME_CONDITION +
") VALUES (?,?,?,?,?,?);";
SQLiteStatement statement = db.compileStatement(sql);
double maxEnergyGenerated = Double.MIN_VALUE;
for (DailyPvDatum dailyPvDatum : dailyPvData) {
statement.clearBindings();
statement.bindLong(1, dailyPvDatum.getYear());
statement.bindLong(2, dailyPvDatum.getMonth());
statement.bindLong(3, dailyPvDatum.getDay());
statement.bindDouble(4, dailyPvDatum.getEnergyGenerated());
statement.bindDouble(5, dailyPvDatum.getPeakPower());
statement.bindString(6, dailyPvDatum.getCondition());
statement.execute();
maxEnergyGenerated = Math.max(maxEnergyGenerated, dailyPvDatum.getEnergyGenerated());
}
db.setTransactionSuccessful();
db.endTransaction();
db.close();
Log.d(TAG, "Saved " + dailyPvData.size() + " rows of daily PV data to database");
RecordPvDatum recordPvDatum = loadRecord();
if (maxEnergyGenerated > recordPvDatum.getDailyEnergyGenerated()) {
recordPvDatum.setDailyEnergyGenerated(maxEnergyGenerated);
saveRecord(recordPvDatum);
}
}
示例7: saveLive
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void saveLive(List<LivePvDatum> livePvData) {
SQLiteDatabase db = pvDataHelper.getWritableDatabase();
db.beginTransaction();
String sql = "REPLACE INTO " + PvDataContract.LivePvData.TABLE_NAME +
"(" + PvDataContract.LivePvData.COLUMN_NAME_YEAR +
"," + PvDataContract.LivePvData.COLUMN_NAME_MONTH +
"," + PvDataContract.LivePvData.COLUMN_NAME_DAY +
"," + PvDataContract.LivePvData.COLUMN_NAME_HOUR +
"," + PvDataContract.LivePvData.COLUMN_NAME_MINUTE +
"," + PvDataContract.LivePvData.COLUMN_NAME_ENERGY_GENERATION +
"," + PvDataContract.LivePvData.COLUMN_NAME_POWER_GENERATION +
") VALUES (?,?,?,?,?,?,?);";
SQLiteStatement statement = db.compileStatement(sql);
double maxPowerGeneration = Double.MIN_VALUE;
for (LivePvDatum livePvDatum : livePvData) {
statement.clearBindings();
statement.bindLong(1, livePvDatum.getYear());
statement.bindLong(2, livePvDatum.getMonth());
statement.bindLong(3, livePvDatum.getDay());
statement.bindLong(4, livePvDatum.getHour());
statement.bindLong(5, livePvDatum.getMinute());
statement.bindDouble(6, livePvDatum.getEnergyGeneration());
statement.bindDouble(7, livePvDatum.getPowerGeneration());
statement.execute();
maxPowerGeneration = Math.max(maxPowerGeneration, livePvDatum.getPowerGeneration());
}
db.setTransactionSuccessful();
db.endTransaction();
db.close();
Log.d(TAG, "Saved " + livePvData.size() + " rows of live PV data to database");
RecordPvDatum recordPvDatum = loadRecord();
if (maxPowerGeneration > recordPvDatum.getLivePowerGeneration()) {
recordPvDatum.setLivePowerGeneration(maxPowerGeneration);
saveRecord(recordPvDatum);
}
}
示例8: saveMonthly
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void saveMonthly(List<MonthlyPvDatum> monthlyPvData) {
SQLiteDatabase db = pvDataHelper.getWritableDatabase();
db.beginTransaction();
String sql = "REPLACE INTO " + PvDataContract.MonthlyPvData.TABLE_NAME +
"(" + PvDataContract.MonthlyPvData.COLUMN_NAME_YEAR +
"," + PvDataContract.MonthlyPvData.COLUMN_NAME_MONTH +
"," + PvDataContract.MonthlyPvData.COLUMN_NAME_ENERGY_GENERATED +
") VALUES (?,?,?);";
SQLiteStatement statement = db.compileStatement(sql);
double maxEnergyGenerated = Double.MIN_VALUE;
for (MonthlyPvDatum monthlyPvDatum : monthlyPvData) {
statement.clearBindings();
statement.bindLong(1, monthlyPvDatum.getYear());
statement.bindLong(2, monthlyPvDatum.getMonth());
statement.bindDouble(3, monthlyPvDatum.getEnergyGenerated());
statement.execute();
maxEnergyGenerated = Math.max(maxEnergyGenerated, monthlyPvDatum.getEnergyGenerated());
}
db.setTransactionSuccessful();
db.endTransaction();
db.close();
Log.d(TAG, "Saved " + monthlyPvData.size() + " rows of monthly PV data to database");
RecordPvDatum recordPvDatum = loadRecord();
if (maxEnergyGenerated > recordPvDatum.getMonthlyEnergyGenerated()) {
recordPvDatum.setMonthlyEnergyGenerated(maxEnergyGenerated);
saveRecord(recordPvDatum);
}
}
示例9: saveYearly
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void saveYearly(List<YearlyPvDatum> yearlyPvData) {
SQLiteDatabase db = pvDataHelper.getWritableDatabase();
db.beginTransaction();
String sql = "REPLACE INTO " + PvDataContract.YearlyPvData.TABLE_NAME +
"(" + PvDataContract.YearlyPvData.COLUMN_NAME_YEAR +
"," + PvDataContract.YearlyPvData.COLUMN_NAME_ENERGY_GENERATED +
") VALUES (?,?);";
SQLiteStatement statement = db.compileStatement(sql);
double maxEnergyGenerated = Double.MIN_VALUE;
for (YearlyPvDatum yearlyPvDatum : yearlyPvData) {
statement.clearBindings();
statement.bindLong(1, yearlyPvDatum.getYear());
statement.bindDouble(2, yearlyPvDatum.getEnergyGenerated());
statement.execute();
maxEnergyGenerated = Math.max(maxEnergyGenerated, yearlyPvDatum.getEnergyGenerated());
}
db.setTransactionSuccessful();
db.endTransaction();
db.close();
Log.d(TAG, "Saved " + yearlyPvData.size() + " rows of yearly PV data to database");
RecordPvDatum recordPvDatum = loadRecord();
if (maxEnergyGenerated > recordPvDatum.getYearlyEnergyGenerated()) {
recordPvDatum.setYearlyEnergyGenerated(maxEnergyGenerated);
saveRecord(recordPvDatum);
}
}
示例10: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, Statistic entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getName());
stmt.bindDouble(3, entity.getQuantity());
stmt.bindDouble(4, entity.getTotalCost());
stmt.bindLong(5, entity.getUnit() ? 1L: 0L);
stmt.bindLong(6, entity.getDate());
}
示例11: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, Product entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getName());
stmt.bindDouble(3, entity.getCost());
}
示例12: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, SimpleEntity entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
Boolean simpleBoolean = entity.getSimpleBoolean();
if (simpleBoolean != null) {
stmt.bindLong(2, simpleBoolean ? 1L: 0L);
}
Byte simpleByte = entity.getSimpleByte();
if (simpleByte != null) {
stmt.bindLong(3, simpleByte);
}
Short simpleShort = entity.getSimpleShort();
if (simpleShort != null) {
stmt.bindLong(4, simpleShort);
}
Integer simpleInt = entity.getSimpleInt();
if (simpleInt != null) {
stmt.bindLong(5, simpleInt);
}
Long simpleLong = entity.getSimpleLong();
if (simpleLong != null) {
stmt.bindLong(6, simpleLong);
}
Float simpleFloat = entity.getSimpleFloat();
if (simpleFloat != null) {
stmt.bindDouble(7, simpleFloat);
}
Double simpleDouble = entity.getSimpleDouble();
if (simpleDouble != null) {
stmt.bindDouble(8, simpleDouble);
}
String simpleString = entity.getSimpleString();
if (simpleString != null) {
stmt.bindString(9, simpleString);
}
byte[] simpleByteArray = entity.getSimpleByteArray();
if (simpleByteArray != null) {
stmt.bindBlob(10, simpleByteArray);
}
}
示例13: runCase
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
public Metrics runCase() {
mDbHelper = new DbHelper(App.getInstance(), getClass().getName());
Metrics result = new Metrics(getClass().getSimpleName()+" ("+mInsertions+" insertions)", mTestSizeIndex);
SQLiteDatabase db = mDbHelper.getWritableDatabase();
Charset ascii = Charset.forName("US-ASCII");
byte[] titleByteArry = new byte[50];
byte[] urlByteArray = new byte[100];
byte[] lyricsByteArray = new byte[2000];
byte[] aboutByteArray = new byte[2000];
result.started();
db.beginTransaction();
SQLiteStatement stmt = db.compileStatement("INSERT INTO tracks (id, title, band_id, duration, url, lyrics, about, release_date, mod_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
for (int i = 0; i < mInsertions; i++) {
mRandom.nextBytes(titleByteArry);
mRandom.nextBytes(urlByteArray);
mRandom.nextBytes(lyricsByteArray);
mRandom.nextBytes(aboutByteArray);
stmt.bindLong(1, i);
stmt.bindString(2, new String(titleByteArry, ascii));
stmt.bindLong(3, mRandom.nextInt());
stmt.bindDouble(4, mRandom.nextDouble());
stmt.bindString(5, new String(urlByteArray, ascii));
stmt.bindString(6, new String(lyricsByteArray, ascii));
stmt.bindString(7, new String(aboutByteArray, ascii));
stmt.bindLong(8, mRandom.nextLong());
stmt.bindLong(9, mRandom.nextLong());
stmt.executeInsert();
stmt.clearBindings();
}
db.setTransactionSuccessful();
db.endTransaction();
result.finished();
return result;
}
示例14: doInsertions
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private void doInsertions(SQLiteDatabase db, int total, Map<Integer, SQLiteStatement> statementCache, byte[] titleByteArray, byte[] urlByteArray, byte[] lyricsByteArray, byte[] aboutByteArray) {
// divide 999 by 9 since that's the # of fields in our table
if (total > 999/9) {
doInsertions(db, total-999/9, statementCache, titleByteArray, urlByteArray, lyricsByteArray, aboutByteArray);
total = 999/9;
}
SQLiteStatement stmt;
if (statementCache.containsKey(total)) {
stmt = statementCache.get(total);
} else {
StringBuilder valueBuilder = new StringBuilder();
for (int i = 0; i < total; i++) {
if (i > 0) {
valueBuilder.append(", ");
}
valueBuilder.append("(?, ?, ?, ?, ?, ?, ?, ?, ?)");
}
stmt = db.compileStatement("INSERT INTO tracks (id, title, band_id, duration, url, lyrics, about, release_date, mod_date) VALUES "+valueBuilder.toString());
statementCache.put(total, stmt);
}
Charset ascii = Charset.forName("US-ASCII");
for (int i = 0; i < total; i++) {
mRandom.nextBytes(titleByteArray);
mRandom.nextBytes(urlByteArray);
mRandom.nextBytes(lyricsByteArray);
mRandom.nextBytes(aboutByteArray);
stmt.bindLong(9*i+1, mInsertId++);
stmt.bindString(9*i+2, new String(titleByteArray, ascii));
stmt.bindLong(9*i+3, mRandom.nextInt());
stmt.bindDouble(9*i+4, mRandom.nextDouble());
stmt.bindString(9*i+5, new String(urlByteArray, ascii));
stmt.bindString(9*i+6, new String(lyricsByteArray, ascii));
stmt.bindString(9*i+7, new String(aboutByteArray, ascii));
stmt.bindLong(9*i+8, mRandom.nextLong());
stmt.bindLong(9*i+9, mRandom.nextLong());
}
stmt.executeInsert();
stmt.clearBindings();
}