本文整理汇总了Java中android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException类的典型用法代码示例。如果您正苦于以下问题:Java SQLiteBindOrColumnIndexOutOfRangeException类的具体用法?Java SQLiteBindOrColumnIndexOutOfRangeException怎么用?Java SQLiteBindOrColumnIndexOutOfRangeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteBindOrColumnIndexOutOfRangeException类属于android.database.sqlite包,在下文中一共展示了SQLiteBindOrColumnIndexOutOfRangeException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSqliteError
import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException; //导入依赖的package包/类
private void onSqliteError(SQLiteException e) {
if (
e instanceof SQLiteBindOrColumnIndexOutOfRangeException ||
e instanceof SQLiteConstraintException ||
e instanceof SQLiteDatabaseCorruptException ||
e instanceof SQLiteDatatypeMismatchException
) {
// If a migration did not go well, the best we can do is drop the database and re-create
// it from scratch. This is hackish but should allow more or less graceful recoveries.
TrackHelper.track().event("Office", "cache.db.error").name("critical").value(1f).with(tracker);
Log.e(TAG, "Critical database error. Droping + Re-creating", e);
close();
ctx.deleteDatabase(DB_NAME);
} else {
// Generic error. Close + re-open
Log.e(TAG, "Datable "+e.getClass().getName()+". Closing + re-opening", e);
TrackHelper.track().event("Office", "cache.db.error").name(e.getClass().getName()).value(1f).with(tracker);
close();
}
}
示例2: bindArguments
import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException; //导入依赖的package包/类
private void bindArguments(PreparedStatement statement, Object[] bindArgs) {
final int count = bindArgs != null ? bindArgs.length : 0;
if (count != statement.mNumParameters) {
String message = "Expected " + statement.mNumParameters + " bind arguments but "
+ count + " were provided.";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
throw new SQLiteBindOrColumnIndexOutOfRangeException(message);
} else {
throw new SQLiteException(message);
}
}
if (count == 0) {
return;
}
final long statementPtr = statement.mStatementPtr;
for (int i = 0; i < count; i++) {
final Object arg = bindArgs[i];
switch (getTypeOfObject(arg)) {
case Cursor.FIELD_TYPE_NULL:
nativeBindNull(mConnectionPtr, statementPtr, i + 1);
break;
case Cursor.FIELD_TYPE_INTEGER:
nativeBindLong(mConnectionPtr, statementPtr, i + 1,
((Number)arg).longValue());
break;
case Cursor.FIELD_TYPE_FLOAT:
nativeBindDouble(mConnectionPtr, statementPtr, i + 1,
((Number)arg).doubleValue());
break;
case Cursor.FIELD_TYPE_BLOB:
nativeBindBlob(mConnectionPtr, statementPtr, i + 1, (byte[])arg);
break;
case Cursor.FIELD_TYPE_STRING:
default:
if (arg instanceof Boolean) {
// Provide compatibility with legacy applications which may pass
// Boolean values in bind args.
nativeBindLong(mConnectionPtr, statementPtr, i + 1, (Boolean) arg ? 1 : 0);
} else {
nativeBindString(mConnectionPtr, statementPtr, i + 1, arg.toString());
}
break;
}
}
}