本文整理匯總了Java中android.database.sqlite.SQLiteStatement.bindNull方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteStatement.bindNull方法的具體用法?Java SQLiteStatement.bindNull怎麽用?Java SQLiteStatement.bindNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.sqlite.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.bindNull方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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");
}
}
}
示例2: 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;
}
示例3: addEncryptedStingToStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static void addEncryptedStingToStatement(MasterCipher masterCipher, SQLiteStatement statement, int index, String value) {
if (value == null || value.equals("null")) {
statement.bindNull(index);
} else {
statement.bindString(index, masterCipher.encryptBody(value));
}
}
示例4: addEncryptedStringToStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static void addEncryptedStringToStatement(Context context, SQLiteStatement statement,
Cursor cursor, MasterSecret masterSecret,
int index, String key)
{
int columnIndex = cursor.getColumnIndexOrThrow(key);
if (cursor.isNull(columnIndex)) {
statement.bindNull(index);
} else {
statement.bindString(index, encrypt(masterSecret, cursor.getString(columnIndex)));
}
}
示例5: addStringToStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static void addStringToStatement(SQLiteStatement statement, Cursor cursor,
int index, String key)
{
int columnIndex = cursor.getColumnIndexOrThrow(key);
if (cursor.isNull(columnIndex)) {
statement.bindNull(index);
} else {
statement.bindString(index, cursor.getString(columnIndex));
}
}
示例6: addIntToStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static void addIntToStatement(SQLiteStatement statement, Cursor cursor,
int index, String key)
{
int columnIndex = cursor.getColumnIndexOrThrow(key);
if (cursor.isNull(columnIndex)) {
statement.bindNull(index);
} else {
statement.bindLong(index, cursor.getLong(columnIndex));
}
}
示例7: Picture_Insert
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void Picture_Insert(String country, String city, String latitude, String longitude,
byte[] thumbnail, String mainImg) {
// open read and write database
SQLiteDatabase db = getWritableDatabase();
// execute insert query
SQLiteStatement p = db.compileStatement("INSERT INTO Picture values(?,?,?,?,?,?,?);");
p.bindNull(1);
p.bindString(2, country);
p.bindString(3, city);
p.bindString(4, latitude);
p.bindString(5, longitude);
p.bindBlob(6, thumbnail);
p.bindString(7, mainImg);
p.execute();
db.close();
Log.d("Database :", "INSERT Complete!");
}
示例8: addEncryptedStringToStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static void addEncryptedStringToStatement(MasterCipher masterCipher, SQLiteStatement statement, int index, String value) {
if (value == null || value.equals("null")) {
statement.bindNull(index);
} else {
statement.bindString(index, masterCipher.encryptBody(value));
}
}
示例9: updateWallpapers
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateWallpapers(@NonNull List<Wallpaper> wallpapers) {
if (!openDatabase()) {
LogUtil.e("Database error: updateWallpapers() failed to open database");
return;
}
String query = "UPDATE " +TABLE_WALLPAPERS+ " SET " +KEY_FAVORITE+ " = ?, " +KEY_SIZE+ " = ?, "
+KEY_MIME_TYPE+ " = ?, " +KEY_WIDTH+ " = ?," +KEY_HEIGHT+ " = ?, " +KEY_COLOR+ " = ? "
+"WHERE " +KEY_URL+ " = ?";
SQLiteStatement statement = mDatabase.get().mSQLiteDatabase.compileStatement(query);
mDatabase.get().mSQLiteDatabase.beginTransaction();
for (Wallpaper wallpaper : wallpapers) {
statement.clearBindings();
statement.bindLong(1, wallpaper.isFavorite() ? 1 : 0);
statement.bindLong(2, wallpaper.getSize());
String mimeType = wallpaper.getMimeType();
if (mimeType != null) {
statement.bindString(3, mimeType);
} else {
statement.bindNull(3);
}
ImageSize dimension = wallpaper.getDimensions();
int width = dimension == null ? 0 : dimension.getWidth();
int height = dimension == null ? 0 : dimension.getHeight();
statement.bindLong(4, width);
statement.bindLong(5, height);
statement.bindLong(6, wallpaper.getColor());
statement.bindString(7, wallpaper.getUrl());
statement.execute();
}
mDatabase.get().mSQLiteDatabase.setTransactionSuccessful();
mDatabase.get().mSQLiteDatabase.endTransaction();
}
示例10: addStringToStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static void addStringToStatement(SQLiteStatement statement, int index, String value) {
if (value == null || value.equals("null")) statement.bindNull(index);
else statement.bindString(index, value);
}
示例11: addNullToStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private static void addNullToStatement(SQLiteStatement statement, int index) {
statement.bindNull(index);
}
示例12: add
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void add(@NonNull List<?> categoryLIst, @NonNull List<?> wallpaperList) {
if (!openDatabase()) {
LogUtil.e("Database error: add() failed to open database");
return;
}
Iterator categoryIterator = categoryLIst.iterator();
Iterator wallpaperIterator = wallpaperList.iterator();
int size = categoryLIst.size() > wallpaperList.size() ? categoryLIst.size() : wallpaperList.size();
String categoryQuery = "INSERT OR IGNORE INTO " +TABLE_CATEGORIES+ " (" +KEY_NAME+ ") VALUES (?);";
String wallpaperQuery = "INSERT OR IGNORE INTO " +TABLE_WALLPAPERS+ " (" +KEY_NAME+ "," +KEY_AUTHOR+ "," +KEY_URL+ ","
+KEY_THUMB_URL+ "," +KEY_CATEGORY+ "," +KEY_ADDED_ON+ ") VALUES (?,?,?,?,?,?);";
SQLiteStatement categoryStatements = mDatabase.get().mSQLiteDatabase.compileStatement(categoryQuery);
SQLiteStatement wallpaperStatements = mDatabase.get().mSQLiteDatabase.compileStatement(wallpaperQuery);
mDatabase.get().mSQLiteDatabase.beginTransaction();
int i = 0;
do {
categoryStatements.clearBindings();
wallpaperStatements.clearBindings();
if (categoryIterator.hasNext()) {
Category category;
if (categoryIterator.next() instanceof Category) {
category = (Category) categoryLIst.get(i);
} else {
category = JsonHelper.getCategory(categoryLIst.get(i));
}
if (category != null) {
categoryStatements.bindString(1, category.getName());
categoryStatements.execute();
}
}
if (wallpaperIterator.hasNext()) {
Wallpaper wallpaper;
if (wallpaperIterator.next() instanceof Wallpaper) {
wallpaper = (Wallpaper) wallpaperList.get(i);
} else {
wallpaper = JsonHelper.getWallpaper(wallpaperList.get(i));
}
if (wallpaper != null) {
if (wallpaper.getUrl() != null) {
String name = wallpaper.getName();
if (name == null) name = "";
wallpaperStatements.bindString(1, name);
if (wallpaper.getAuthor() != null) {
wallpaperStatements.bindString(2, wallpaper.getAuthor());
} else {
wallpaperStatements.bindNull(2);
}
wallpaperStatements.bindString(3, wallpaper.getUrl());
wallpaperStatements.bindString(4, wallpaper.getThumbUrl());
wallpaperStatements.bindString(5, wallpaper.getCategory());
wallpaperStatements.bindString(6, TimeHelper.getLongDateTime());
wallpaperStatements.execute();
}
}
}
i++;
} while (i < size);
mDatabase.get().mSQLiteDatabase.setTransactionSuccessful();
mDatabase.get().mSQLiteDatabase.endTransaction();
}
示例13: addWallpapers
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void addWallpapers(@NonNull List<?> list) {
if (!openDatabase()) {
LogUtil.e("Database error: addWallpapers() failed to open database");
return;
}
String query = "INSERT OR IGNORE INTO " +TABLE_WALLPAPERS+ " (" +KEY_NAME+ "," +KEY_AUTHOR+ "," +KEY_URL+ ","
+KEY_THUMB_URL+ "," +KEY_CATEGORY+ "," +KEY_ADDED_ON+ ") VALUES (?,?,?,?,?,?);";
SQLiteStatement statement = mDatabase.get().mSQLiteDatabase.compileStatement(query);
mDatabase.get().mSQLiteDatabase.beginTransaction();
for (int i = 0; i < list.size(); i++) {
statement.clearBindings();
Wallpaper wallpaper;
if (list.get(i) instanceof Wallpaper) {
wallpaper = (Wallpaper) list.get(i);
} else {
wallpaper = JsonHelper.getWallpaper(list.get(i));
}
if (wallpaper != null) {
if (wallpaper.getUrl() != null) {
String name = wallpaper.getName();
if (name == null) name = "";
statement.bindString(1, name);
if (wallpaper.getAuthor() != null) {
statement.bindString(2, wallpaper.getAuthor());
} else {
statement.bindNull(2);
}
statement.bindString(3, wallpaper.getUrl());
statement.bindString(4, wallpaper.getThumbUrl());
statement.bindString(5, wallpaper.getCategory());
statement.bindString(6, TimeHelper.getLongDateTime());
statement.execute();
}
}
}
mDatabase.get().mSQLiteDatabase.setTransactionSuccessful();
mDatabase.get().mSQLiteDatabase.endTransaction();
}