本文整理汇总了Java中android.database.sqlite.SQLiteDiskIOException类的典型用法代码示例。如果您正苦于以下问题:Java SQLiteDiskIOException类的具体用法?Java SQLiteDiskIOException怎么用?Java SQLiteDiskIOException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteDiskIOException类属于android.database.sqlite包,在下文中一共展示了SQLiteDiskIOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readExceptionFromParcel
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
private static final void readExceptionFromParcel(Parcel reply, String msg, int code) {
switch (code) {
case 2:
throw new IllegalArgumentException(msg);
case 3:
throw new UnsupportedOperationException(msg);
case 4:
throw new SQLiteAbortException(msg);
case 5:
throw new SQLiteConstraintException(msg);
case 6:
throw new SQLiteDatabaseCorruptException(msg);
case 7:
throw new SQLiteFullException(msg);
case 8:
throw new SQLiteDiskIOException(msg);
case 9:
throw new SQLiteException(msg);
case 11:
throw new OperationCanceledException(msg);
default:
reply.readException(code, msg);
}
}
示例2: put
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
/**
* Stores the image with the given URL and the modified/version String.
*
* @param url
* The URL of the photo to be put.
* @param modified
* The modified/version string.
* @param image
* The image data.
*/
private synchronized boolean put(URL url, String modified, Bitmap image) {
if (!imageDb.isReady()) {
return false;
}
Log.i(TAG, "Attempting to put " + url.toString());
if (imageDb.exists(url)) {
Log.i(TAG, "ALREADY EXISTS!");
return false;
}
Log.i(TAG, "Putting photo into DB.");
try {
return imageDb.put(url, modified, image) != -1;
} catch (SQLiteDiskIOException ex) {
Log.w(TAG, "Unable to put photo in DB, disk full or unavailable.");
return false;
}
}
示例3: writeToDb
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
private void writeToDb(Object o, Bitmap preview) {
String name = getObjectName(o);
SQLiteDatabase db = mDb.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(CacheDb.COLUMN_NAME, name);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
preview.compress(Bitmap.CompressFormat.PNG, 100, stream);
values.put(CacheDb.COLUMN_PREVIEW_BITMAP, stream.toByteArray());
values.put(CacheDb.COLUMN_SIZE, mSize);
try {
db.insert(CacheDb.TABLE_NAME, null, values);
} catch (SQLiteDiskIOException e) {
recreateDb();
}
}
示例4: removePackageFromDb
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public static void removePackageFromDb(final CacheDb cacheDb, final String packageName) {
synchronized(sInvalidPackages) {
sInvalidPackages.add(packageName);
}
new AsyncTask<Void, Void, Void>() {
public Void doInBackground(Void ... args) {
SQLiteDatabase db = cacheDb.getWritableDatabase();
try {
db.delete(CacheDb.TABLE_NAME,
CacheDb.COLUMN_NAME + " LIKE ? OR " +
CacheDb.COLUMN_NAME + " LIKE ?", // SELECT query
new String[] {
WIDGET_PREFIX + packageName + "/%",
SHORTCUT_PREFIX + packageName + "/%"
} // args to SELECT query
);
} catch (SQLiteDiskIOException e) {
}
synchronized(sInvalidPackages) {
sInvalidPackages.remove(packageName);
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}
示例5: selectCalibAlgo
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public int selectCalibAlgo( long cid )
{
int algo = CalibInfo.ALGO_AUTO; // default
// if ( myDB == null ) return 0;
Cursor cursor = null;
try {
cursor = myDB.query( CALIB_TABLE,
new String[] { "algo" }, // columns
"id=?",
new String[] { Long.toString(cid) },
null, null, null );
if ( cursor != null && cursor.moveToFirst()) {
algo = (int)cursor.getLong( 0 );
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return algo;
}
示例6: getCalibCID
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public long getCalibCID( String name, String device )
{
long id = -1L;
Cursor cursor = null;
try {
cursor = myDB.query( CALIB_TABLE,
new String[] { "id" }, // columns
"name=? and device=?",
new String[] { name, device },
null, null, null );
if (cursor != null && cursor.moveToFirst()) {
id = cursor.getLong( 0 );
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return id;
}
示例7: selectCalibInfo
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public CalibInfo selectCalibInfo( long cid )
{
CalibInfo info = null;
// if ( myDB == null ) return null;
Cursor cursor = null;
try {
cursor = myDB.query( CALIB_TABLE,
new String[] { "name", "day", "device", "comment", "algo" }, // columns
"id=?",
new String[] { Long.toString(cid) },
null, null, null );
if ( cursor != null && cursor.moveToFirst()) {
info = new CalibInfo(
cid,
cursor.getString( 0 ),
cursor.getString( 1 ),
cursor.getString( 2 ),
cursor.getString( 3 ),
(int)cursor.getLong( 4 ) );
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return info;
}
示例8: selectCalibCoeff
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public String selectCalibCoeff( long cid )
{
String coeff = null;
// if ( myDB == null ) return null;
Cursor cursor = null;
try {
cursor = myDB.query( CALIB_TABLE,
new String[] { "coeff" }, // columns
"id=?",
new String[] { Long.toString(cid) },
null, null, null );
if ( cursor != null && cursor.moveToFirst()) {
coeff = cursor.getString( 0 );
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return coeff;
}
示例9: selectAllNames
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
private List<String> selectAllNames( String table )
{
TDLog.Log( TDLog.LOG_DB, "selectAllNames table " + table );
List< String > list = new ArrayList<>();
// if ( myDB == null ) return list;
Cursor cursor = null;
try {
cursor = myDB.query( table,
new String[] { "name" }, // columns
null, null, null, null, "name" );
if (cursor.moveToFirst()) {
do {
list.add( cursor.getString(0) );
} while (cursor.moveToNext());
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
TDLog.Log( TDLog.LOG_DB, "found " + list.size() + " names " );
return list;
}
示例10: selectDeviceCalibs
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public List<String> selectDeviceCalibs( String device )
{
List<String> ret = new ArrayList<>();
Cursor cursor = null;
try {
cursor = myDB.query( CALIB_TABLE,
new String[] { "name", "day" }, // columns
"device=?",
new String[] { device },
null, null, null );
if (cursor != null && cursor.moveToFirst() ) {
do {
ret.add( cursor.getString(0) + " - " + cursor.getString(1) );
} while (cursor.moveToNext());
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return ret;
}
示例11: selectDeviceCalibsInfo
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public List<CalibInfo> selectDeviceCalibsInfo( String device )
{
List<CalibInfo> ret = new ArrayList<>();
Cursor cursor = null;
try {
cursor = myDB.query( CALIB_TABLE,
new String[] { "id", "name", "day", "comment", "algo" }, // columns
"device=?",
new String[] { device },
null, null, null );
if (cursor != null && cursor.moveToFirst() ) {
do {
ret.add( new CalibInfo(
cursor.getLong(0),
cursor.getString(1),
cursor.getString(2),
device,
cursor.getString(3),
(int)cursor.getLong(4) ) );
} while (cursor.moveToNext());
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return ret;
}
示例12: getValue
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
public String getValue( String key )
{
if ( myDB == null ) {
TDLog.Error( "DeviceHelper::getValue null DB");
return null;
}
if ( key == null || key.length() == 0 ) {
TDLog.Error( "DeviceHelper::getValue null key");
return null;
}
String value = null;
Cursor cursor = null;
try {
cursor = myDB.query( CONFIG_TABLE,
new String[] { "value" }, // columns
"key = ?", new String[] { key },
null, null, null );
if ( cursor != null && cursor.moveToFirst()) {
value = cursor.getString( 0 );
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return value;
}
示例13: getNameFromId
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
private String getNameFromId( String table, long id )
{
String ret = null;
// if ( myDB == null ) return null;
Cursor cursor = null;
try {
cursor = myDB.query( table, new String[] { "name" },
"id=?", new String[] { Long.toString(id) },
null, null, null );
if (cursor != null && cursor.moveToFirst() ) {
ret = cursor.getString(0);
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return ret;
}
示例14: getIdFromName
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
private long getIdFromName( String table, String name )
{
long id = -1;
// if ( myDB == null ) { return -2; }
Cursor cursor = null;
try {
cursor = myDB.query( table, new String[] { "id" },
"name = ?", new String[] { name },
null, null, null );
if (cursor != null && cursor.moveToFirst() ) {
id = cursor.getLong(0);
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return id;
}
示例15: maxId
import android.database.sqlite.SQLiteDiskIOException; //导入依赖的package包/类
private long maxId( String table, long sid )
{
long id = 1;
// if ( myDB == null ) return 1L;
Cursor cursor = null;
try {
cursor = myDB.query( table, new String[] { "max(id)" },
"surveyId=?",
new String[] { Long.toString(sid) },
null, null, null );
if (cursor != null && cursor.moveToFirst() ) {
id = 1 + cursor.getLong(0);
}
} catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
} finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
return id;
}