Java Code Examples for android.database.sqlite.SQLiteStatement#bindDouble()
The following examples show how to use
android.database.sqlite.SQLiteStatement#bindDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: X8AiLinePointLatlngInfoDao.java From FimiX8-RE with MIT License | 6 votes |
public final void bindValues(SQLiteStatement stmt, X8AiLinePointLatlngInfo entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id.longValue()); } stmt.bindLong(2, (long) entity.getNumber()); stmt.bindLong(3, (long) entity.getTotalnumber()); stmt.bindDouble(4, entity.getLongitude()); stmt.bindDouble(5, entity.getLatitude()); stmt.bindLong(6, (long) entity.getAltitude()); stmt.bindDouble(7, (double) entity.getYaw()); stmt.bindLong(8, (long) entity.getGimbalPitch()); stmt.bindLong(9, (long) entity.getSpeed()); stmt.bindLong(10, (long) entity.getYawMode()); stmt.bindLong(11, (long) entity.getGimbalMode()); stmt.bindLong(12, (long) entity.getTrajectoryMode()); stmt.bindLong(13, (long) entity.getMissionFinishAction()); stmt.bindLong(14, (long) entity.getRCLostAction()); stmt.bindDouble(15, entity.getLongitudePOI()); stmt.bindDouble(16, entity.getLatitudePOI()); stmt.bindLong(17, (long) entity.getAltitudePOI()); stmt.bindLong(18, entity.getLineId()); stmt.bindLong(19, (long) entity.getPointActionCmd()); stmt.bindLong(20, (long) entity.getRoration()); }
Example 2
Source File: SQLitePlugin.java From react-native-sqlite-storage with MIT License | 6 votes |
private void bindArgsToStatement(SQLiteStatement myStatement, ReadableArray sqlArgs) { for (int i = 0; i < sqlArgs.size(); i++) { ReadableType type = sqlArgs.getType(i); if (type == ReadableType.Number){ double tmp = sqlArgs.getDouble(i); if (tmp == (long) tmp) { myStatement.bindLong(i + 1, (long) tmp); } else { myStatement.bindDouble(i + 1, tmp); } } else if (sqlArgs.isNull(i)) { myStatement.bindNull(i + 1); } else { myStatement.bindString(i + 1, SQLitePluginConverter.getString(sqlArgs,i,"")); } } }
Example 3
Source File: SQLiteAndroidDatabase.java From react-native-sqlite-storage with MIT License | 6 votes |
private void bindArgsToStatement(SQLiteStatement myStatement, ReadableArray sqlArgs) { if (sqlArgs == null) return; for (int i = 0; i < sqlArgs.size(); i++) { ReadableType type = sqlArgs.getType(i); if (type == ReadableType.Number) { double tmp = sqlArgs.getDouble(i); if (tmp == (long) tmp) { myStatement.bindLong(i + 1, (long) tmp); } else { myStatement.bindDouble(i + 1, tmp); } } else if (sqlArgs.isNull(i)) { myStatement.bindNull(i + 1); } else { myStatement.bindString(i + 1, sqlArgs.getString(i)); } } }
Example 4
Source File: MessageDao.java From android-orm-benchmark-updated with Apache License 2.0 | 6 votes |
@Override protected final void bindValues(SQLiteStatement stmt, Message entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } String content = entity.getContent(); if (content != null) { stmt.bindString(2, content); } stmt.bindLong(3, entity.getClient_id()); stmt.bindLong(4, entity.getCreated_at()); stmt.bindDouble(5, entity.getSorted_by()); stmt.bindLong(6, entity.getCommand_id()); stmt.bindLong(7, entity.getSender_id()); stmt.bindLong(8, entity.getChannel_id()); }
Example 5
Source File: Benchmark.java From sqlite-android with Apache License 2.0 | 6 votes |
private void testAndroidSQLiteWrite(Statistics statistics) { Trace trace = new Trace("Android Write"); SQLiteDatabase db = platformSQLite.getReadableDatabase(); SQLiteStatement statement = db.compileStatement( String.format("insert into %s (%s, %s) values (?,?)", Record.TABLE_NAME, Record.COLUMN_CONTENT, Record.COLUMN_CREATED_TIME)); try { db.beginTransaction(); for (int i = 0; i < COUNT; i++) { Record record = Record.create(i); statement.bindString(1, record.getContent()); statement.bindDouble(2, record.getCreatedTime()); long id = statement.executeInsert(); record.setId(id); } db.setTransactionSuccessful(); } finally { db.endTransaction(); } statistics.write( trace.exit() ); }
Example 6
Source File: GH2DataStaticInfoDao.java From FimiX8-RE with MIT License | 6 votes |
public final void bindValues(SQLiteStatement stmt, GH2DataStaticInfo entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id.longValue()); } String productModel = entity.getProductModel(); if (productModel != null) { stmt.bindString(2, productModel); } stmt.bindLong(3, (long) entity.getHandleVersion()); stmt.bindLong(4, (long) entity.getGimbalVersion()); stmt.bindDouble(5, entity.getUseTime()); stmt.bindDouble(6, entity.getLongitude()); stmt.bindDouble(7, entity.getLatitude()); String createTime = entity.getCreateTime(); if (createTime != null) { stmt.bindString(8, createTime); } }
Example 7
Source File: X8AiLinePointInfoDao.java From FimiX8-RE with MIT License | 6 votes |
public final void bindValues(SQLiteStatement stmt, X8AiLinePointInfo entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id.longValue()); } stmt.bindLong(2, entity.getTime()); String name = entity.getName(); if (name != null) { stmt.bindString(3, name); } stmt.bindLong(4, (long) entity.getType()); stmt.bindLong(5, (long) entity.getSpeed()); stmt.bindLong(6, (long) entity.getSaveFlag()); stmt.bindDouble(7, (double) entity.getDistance()); stmt.bindLong(8, (long) entity.getIsCurve()); stmt.bindLong(9, (long) entity.getMapType()); stmt.bindLong(10, (long) entity.getRunByMapOrVedio()); stmt.bindLong(11, (long) entity.getDisconnectType()); stmt.bindLong(12, (long) entity.getExcuteEnd()); stmt.bindLong(13, (long) entity.getAutoRecord()); String locality = entity.getLocality(); if (locality != null) { stmt.bindString(14, locality); } }
Example 8
Source File: SQLiteAndroidDatabase.java From AvI with MIT License | 5 votes |
private void bindArgsToStatement(SQLiteStatement myStatement, JSONArray sqlArgs) throws JSONException { for (int i = 0; i < sqlArgs.length(); i++) { if (sqlArgs.get(i) instanceof Float || sqlArgs.get(i) instanceof Double) { myStatement.bindDouble(i + 1, sqlArgs.getDouble(i)); } else if (sqlArgs.get(i) instanceof Number) { myStatement.bindLong(i + 1, sqlArgs.getLong(i)); } else if (sqlArgs.isNull(i)) { myStatement.bindNull(i + 1); } else { myStatement.bindString(i + 1, sqlArgs.getString(i)); } } }
Example 9
Source File: OptimizedMessage.java From android-orm-benchmark-updated with Apache License 2.0 | 5 votes |
public void prepareForInsert(final SQLiteStatement insertMessage) { insertMessage.bindString(1, mContent); insertMessage.bindDouble(2, mSortedBy); insertMessage.bindLong(3, mClientId); insertMessage.bindLong(4, mSenderId); insertMessage.bindLong(5, mChannelId); insertMessage.bindLong(6, mCommandId); insertMessage.bindLong(7, mCreatedAt); }
Example 10
Source File: BJCameraDao.java From Maps with GNU General Public License v2.0 | 5 votes |
/** @inheritdoc */ @Override protected void bindValues(SQLiteStatement stmt, BJCamera entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } stmt.bindString(2, entity.getName()); String address = entity.getAddress(); if (address != null) { stmt.bindString(3, address); } Double latitude = entity.getLatitude(); if (latitude != null) { stmt.bindDouble(4, latitude); } Double longtitude = entity.getLongtitude(); if (longtitude != null) { stmt.bindDouble(5, longtitude); } String direction = entity.getDirection(); if (direction != null) { stmt.bindString(6, direction); } }
Example 11
Source File: AndroidDB.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
@Override public void execute(String sql, Object... params) throws IOException { try { SQLiteStatement s = db.compileStatement(sql); for (int i = 0; i < params.length; i++) { Object p = params[i]; if(p == null){ s.bindNull(i + 1); }else{ if(p instanceof String){ s.bindString(i + 1, (String)p); }else if(p instanceof byte[]){ s.bindBlob(i + 1, (byte [])p); }else if(p instanceof Double){ s.bindDouble(i + 1, ((Double)p).doubleValue()); } else if(p instanceof Long){ s.bindLong(i + 1, ((Long)p).longValue()); } else if(p instanceof Integer){ s.bindLong(i + 1, ((Integer)p).intValue()); } else { if(p != null) { s.bindString(i + 1, p.toString()); } } } } s.execute(); s.close(); } catch (Exception e) { e.printStackTrace(); throw new IOException(e.getMessage()); } }
Example 12
Source File: SampleModel.java From android-skeleton-project with MIT License | 5 votes |
@Override public void bindStatement(SQLiteStatement statement) throws SQLException { statement.bindLong(SQLITE.table.indexOf(ID), _id); statement.bindString(SQLITE.table.indexOf(SQLITE.COL_NAME), name); statement.bindDouble(SQLITE.table.indexOf(SQLITE.COL_1), field1); statement.bindDouble(SQLITE.table.indexOf(SQLITE.COL_2), field2); }
Example 13
Source File: Session.java From Android-ORM with Apache License 2.0 | 5 votes |
static void bindStatement(SQLiteStatement stmt, int index, Object colValue) { Class<?> colClass = colValue.getClass(); int i = index + 1; if (int.class == colClass || Integer.class == colClass) { stmt.bindLong(i, (Long) colValue); } else if (short.class == colClass || Short.class == colClass) { stmt.bindLong(i, (Long) colValue); } else if (long.class == colClass || Long.class == colClass) { stmt.bindLong(i, (Long) colValue); } else if (byte.class == colClass || Byte.class == colClass) { stmt.bindLong(i, (Long) colValue); } else if (float.class == colClass || Float.class == colClass) { stmt.bindDouble(i, (Double) colValue); } else if (double.class == colClass || Double.class == colClass) { stmt.bindDouble(i, (Double) colValue); } else if (byte[].class == colClass || Byte[].class == colClass) { stmt.bindBlob(i, (byte[]) colValue); } else if (boolean.class == colClass || Boolean.class == colClass) { stmt.bindLong(i, ((Boolean) colValue) ? 1 : 0); } else if (String.class == colClass) { stmt.bindString(i, (String) colValue); } else { stmt.bindString(i, (String) colValue); } }
Example 14
Source File: MessageDao.java From android-orm-benchmark with Apache License 2.0 | 5 votes |
/** @inheritdoc */ @Override protected void bindValues(SQLiteStatement stmt, Message entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } String content = entity.getContent(); if (content != null) { stmt.bindString(2, content); } Long client_id = entity.getClient_id(); if (client_id != null) { stmt.bindLong(3, client_id); } Integer created_at = entity.getCreated_at(); if (created_at != null) { stmt.bindLong(4, created_at); } Double sorted_by = entity.getSorted_by(); if (sorted_by != null) { stmt.bindDouble(5, sorted_by); } Long command_id = entity.getCommand_id(); if (command_id != null) { stmt.bindLong(6, command_id); } stmt.bindLong(7, entity.getSender_id()); stmt.bindLong(8, entity.getChannel_id()); }
Example 15
Source File: AndroidDatabaseConnection.java From ormlite-android with ISC License | 4 votes |
private void bindArgs(SQLiteStatement stmt, Object[] args, FieldType[] argFieldTypes) throws SQLException { if (args == null) { return; } for (int i = 0; i < args.length; i++) { Object arg = args[i]; if (arg == null) { stmt.bindNull(i + 1); } else { SqlType sqlType = argFieldTypes[i].getSqlType(); switch (sqlType) { case STRING: case LONG_STRING: case CHAR: stmt.bindString(i + 1, arg.toString()); break; case BOOLEAN: case BYTE: case SHORT: case INTEGER: case LONG: stmt.bindLong(i + 1, ((Number) arg).longValue()); break; case FLOAT: case DOUBLE: stmt.bindDouble(i + 1, ((Number) arg).doubleValue()); break; case BYTE_ARRAY: case SERIALIZABLE: stmt.bindBlob(i + 1, (byte[]) arg); break; case DATE: // this is mapped to a STRING under Android case BLOB: // this is only for derby serializable case BIG_DECIMAL: // this should be handled as a STRING throw new SQLException("Invalid Android type: " + sqlType); case UNKNOWN: default: throw new SQLException("Unknown sql argument type: " + sqlType); } } } }
Example 16
Source File: SQLiteStatementTestCase.java From SQLite-Performance with The Unlicense | 4 votes |
@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; }
Example 17
Source File: MeasurementManager.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
/** * Add multiple leq records * @param leqBatches List of Leq to add */ public void addLeqBatches(List<LeqBatch> leqBatches) { SQLiteDatabase database = storage.getWritableDatabase(); try { database.beginTransaction(); SQLiteStatement leqStatement = database.compileStatement( "INSERT INTO " + Storage.Leq.TABLE_NAME + "(" + Storage.Leq.COLUMN_RECORD_ID + "," + Storage.Leq.COLUMN_LEQ_UTC + "," + Storage.Leq.COLUMN_LATITUDE + "," + Storage.Leq.COLUMN_LONGITUDE + "," + Storage.Leq.COLUMN_ALTITUDE + "," + Storage.Leq.COLUMN_ACCURACY + "," + Storage.Leq.COLUMN_LOCATION_UTC + "," + Storage.Leq.COLUMN_SPEED + "," + Storage.Leq.COLUMN_BEARING + ") VALUES (?, ?,?,?,?,?,?,?,?)"); SQLiteStatement leqValueStatement = database.compileStatement("INSERT INTO " + Storage.LeqValue.TABLE_NAME + " VALUES (?,?,?)"); for(LeqBatch leqBatch : leqBatches) { Storage.Leq leq = leqBatch.getLeq(); leqStatement.clearBindings(); leqStatement.bindLong(1, leq.getRecordId()); leqStatement.bindLong(2, leq.getLeqUtc()); leqStatement.bindDouble(3, leq.getLatitude()); leqStatement.bindDouble(4, leq.getLongitude()); if(leq.getAltitude() != null) { leqStatement.bindDouble(5, leq.getAltitude()); } else { leqStatement.bindNull(5); } leqStatement.bindDouble(6, leq.getAccuracy()); leqStatement.bindDouble(7, leq.getLocationUTC()); if(leq.getSpeed() != null) { leqStatement.bindDouble(8, leq.getSpeed()); } else { leqStatement.bindNull(8); } if(leq.getBearing() != null) { leqStatement.bindDouble(9, leq.getBearing()); } else { leqStatement.bindNull(9); } long leqId = leqStatement.executeInsert(); for(Storage.LeqValue leqValue : leqBatch.getLeqValues()) { leqValueStatement.clearBindings(); leqValueStatement.bindLong(1, leqId); leqValueStatement.bindLong(2, leqValue.getFrequency()); leqValueStatement.bindDouble(3, leqValue.getSpl()); leqValueStatement.execute(); } } database.setTransactionSuccessful(); database.endTransaction(); } finally { database.close(); } }
Example 18
Source File: PnDb.java From PressureNet with GNU General Public License v3.0 | 4 votes |
public boolean addTemperatureForecastArrayList(ArrayList<TemperatureForecast> tempForecasts) { try { mDB.beginTransaction(); } catch(SQLiteDatabaseLockedException sqldble) { // This try/catch block is a bad hack. Refactor db usaage to use only one lock // regardless of the thread } String insertSQL = "INSERT INTO " + TEMPERATURES + " (" + KEY_FORECAST_LOCATION_ID + ", " + KEY_TEMP_FORECAST_START_TIME + ", " + KEY_TEMP_FORECAST_HOUR + ", " + KEY_TEMP_FORECAST_SCALE + ", " + KEY_TEMP_FORECAST_VALUE + ") values (?, ?, ?, ?, ?)"; try { SQLiteStatement insert = mDB.compileStatement(insertSQL); for (TemperatureForecast temp : tempForecasts) { insert.bindString(1, temp.getLocationID()); insert.bindString(2, temp.getStartTime()); insert.bindLong(3, temp.getForecastHour()); insert.bindLong(4, temp.getScale()); insert.bindDouble(5, temp.getTemperatureValue()); insert.executeInsert(); } mDB.setTransactionSuccessful(); } catch (SQLException sqle) { sqle.printStackTrace(); } finally { mDB.endTransaction(); } return true; }
Example 19
Source File: CbDb.java From PressureNet-SDK with MIT License | 4 votes |
public boolean addCurrentConditionArrayList(ArrayList<CbWeather> weather) { try { mDB.beginTransaction(); } catch(SQLiteDatabaseLockedException sqldble) { // This try/catch block is a bad hack. Refactor db usaage to use only one lock // regardless of the thread } String insertSQL = "INSERT INTO " + CURRENT_CONDITIONS_TABLE + " (" + KEY_LATITUDE + ", " + KEY_LONGITUDE + ", " + KEY_ALTITUDE + ", " + KEY_ACCURACY + ", " + KEY_PROVIDER + ", " + KEY_SHARING + ", " + KEY_TIME + ", " + KEY_TIMEZONE + ", " + KEY_USERID + ", " + KEY_GENERAL_CONDITION + ", " + KEY_WINDY + ", " + KEY_FOGGY + ", " + KEY_CLOUD_TYPE + ", " + KEY_PRECIPITATION_TYPE + ", " + KEY_PRECIPITATION_AMOUNT + ", " + KEY_PRECIPITATION_UNIT + ", " + KEY_THUNDERSTORM_INTENSITY + ", " + KEY_USER_COMMENT + ") values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; try { SQLiteStatement insert = mDB.compileStatement(insertSQL); for (CbWeather weatherItem : weather) { CbCurrentCondition condition = (CbCurrentCondition) weatherItem; insert.bindDouble(1, condition.getLocation().getLatitude()); insert.bindDouble(2, condition.getLocation().getLongitude()); insert.bindDouble(3, condition.getLocation().getAltitude()); insert.bindDouble(4, condition.getLocation().getAccuracy()); insert.bindString(5, condition.getLocation().getProvider()); insert.bindString(6, condition.getSharing_policy()); insert.bindLong(7, condition.getTime()); insert.bindLong(8, condition.getTzoffset()); insert.bindString(9, condition.getUser_id()); insert.bindString(10, condition.getGeneral_condition()); insert.bindString(11, condition.getWindy()); insert.bindString(12, condition.getFog_thickness()); insert.bindString(13, condition.getCloud_type()); insert.bindString(14, condition.getPrecipitation_type()); insert.bindDouble(15, condition.getPrecipitation_amount()); insert.bindString(16, condition.getPrecipitation_unit()); insert.bindString(17, condition.getThunderstorm_intensity()); insert.bindString(18, condition.getUser_comment()); insert.executeInsert(); } mDB.setTransactionSuccessful(); } catch (SQLException sqle) { sqle.printStackTrace(); } finally { mDB.endTransaction(); } return true; }
Example 20
Source File: CbDb.java From PressureNet-SDK with MIT License | 4 votes |
/** * Add a new Observations in an ArrayList * * @return */ public boolean addObservationArrayList(ArrayList<CbWeather> weather, CbApiCall api) { mDB.beginTransaction(); String insertSQL = "INSERT INTO " + API_LIST_TABLE + " (" + KEY_LATITUDE + ", " + KEY_LONGITUDE + ", " + KEY_ALTITUDE + ", " + KEY_TIME + ", " + KEY_OBSERVATION_VALUE + " " + ") values (?, ?, ?, ?, ?)"; try { SQLiteStatement insert = mDB.compileStatement(insertSQL); for (CbWeather weatherItem : weather) { CbObservation ob = (CbObservation) weatherItem; double latitude = ob.getLocation().getLatitude(); double longitude = ob.getLocation().getLongitude(); double altitude = ob.getLocation().getAltitude(); insert.bindDouble(1, latitude); insert.bindDouble(2, longitude); insert.bindDouble(3, altitude); insert.bindLong(4, ob.getTime()); insert.bindDouble(5, ob.getObservationValue()); insert.executeInsert(); } mDB.setTransactionSuccessful(); } catch (SQLException sqle) { sqle.printStackTrace(); } finally { mDB.endTransaction(); } return true; }