Java 类android.database.sqlite.SQLiteDiskIOException 实例源码

项目:YuiHatano    文件:ShadowDatabaseUtils.java   
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);
    }
}
项目:buildAPKsSamples    文件:FileSystemImageCache.java   
/**
 * 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;
  }
}
项目:KBUnitTest    文件:ShadowDatabaseUtils.java   
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);
    }
}
项目:TurboLauncher    文件:WidgetPreviewLoader.java   
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();
    }
}
项目:TurboLauncher    文件:WidgetPreviewLoader.java   
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);
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
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;
}
项目:topodroid    文件:DeviceHelper.java   
public ArrayList< Device > getDevices( ) 
{
  ArrayList<Device> ret = new ArrayList<>();
  // if ( myDB == null ) return ret;
  Cursor cursor = null;
  try {
    cursor = myDB.query( DEVICE_TABLE, new String[] { "address", "model", "head", "tail", "name", "nickname" }, 
                              null, null, null, null, null );
    if (cursor != null && cursor.moveToFirst() ) {
      do {
        ret.add( new Device( cursor.getString(0), 
                             cursor.getString(1),
                             (int)cursor.getLong(2),
                             (int)cursor.getLong(3),
                             cursor.getString(4),
                             cursor.getString(5)
                ) );
      } while (cursor.moveToNext());
    }
  } catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
  } finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
  return ret;
}
项目:topodroid    文件:DeviceHelper.java   
private Device getDeviceByNickname( String nickname )
{
  if ( myDB == null ) return null;
  Device ret = null;
  Cursor cursor = null;
  try {
    cursor = myDB.query( DEVICE_TABLE, new String[] { "address", "model", "head", "tail", "name", "nickname" }, 
                              "nickname=?", new String[] { nickname }, null, null, null );
    if (cursor != null && cursor.moveToFirst() ) {
      ret = new Device( cursor.getString(0), 
                        cursor.getString(1),
                        (int)cursor.getLong(2),
                        (int)cursor.getLong(3),
                        cursor.getString(4),
                        cursor.getString(5)
                      );
    }
  } catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
  } finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
  return ret;
}
项目:topodroid    文件:DeviceHelper.java   
private Device getDeviceByAddress( String addr )
{
  if ( myDB == null ) return null;
  Device ret = null;
  Cursor cursor = null;
  try {
    cursor = myDB.query( DEVICE_TABLE, new String[] { "address", "model", "head", "tail", "name", "nickname" }, 
                              "address=?", new String[] { addr }, null, null, null );
    if (cursor != null && cursor.moveToFirst() ) {
      ret = new Device( cursor.getString(0), 
                        cursor.getString(1),
                        (int)cursor.getLong(2),
                        (int)cursor.getLong(3),
                        cursor.getString(4),
                        cursor.getString(5)
                      );
    }
  } catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
  } finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
  return ret;
}
项目:topodroid    文件:DeviceHelper.java   
public int getDeviceTail( String address )
{ 
  int ret = 0;
  // if ( myDB == null ) return 0;
  Cursor cursor = null;
  try {
    cursor = myDB.query( DEVICE_TABLE, new String[] { "tail" },
                       "address=?", 
                       new String[] { address },
                       null, null, null );
    if (cursor != null && cursor.moveToFirst() ) {
      ret = (int)( cursor.getLong(0) );
    }
  } catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
  } finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
  return ret;
}
项目:topodroid    文件:DeviceHelper.java   
public boolean getDeviceHeadTail( String address, int[] head_tail )
{
  boolean ret = false;
  // if ( myDB == null ) return false;
  Cursor cursor = null;
  try {
    cursor = myDB.query( DEVICE_TABLE, new String[] { "head", "tail" },
                       "address=?", 
                       new String[] { address },
                       null, null, null );
    if (cursor != null && cursor.moveToFirst() ) {
      head_tail[0] = (int)( cursor.getLong(0) );
      head_tail[1] = (int)( cursor.getLong(1) );
      ret = true;
    }
  } catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
  } finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
  return ret;
}
项目:topodroid    文件:DeviceHelper.java   
private boolean hasName( String name, String table )
{
  boolean ret = false;
  // if ( myDB == null ) return ret;
  Cursor cursor = null;
  try {
    cursor = myDB.query( table, new String[] { "id" },
                        "name=?", 
                        new String[] { name },
                        null, null, null );
    if (cursor != null && cursor.moveToFirst() ) {
       ret = true;
    }
  } catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
  } finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
   return ret;
 }
项目:topodroid    文件:DeviceHelper.java   
public long setCalib( String calib ) 
{
  myNextCId = 0;
  // if ( myDB == null ) return 0L;
  long cid = setCalibName( calib );
  Cursor cursor = null;
  try {
    cursor = myDB.query( GM_TABLE, new String[] { "max(id)" },
                       "calibId=?", new String[] { Long.toString(cid) },
                       null, null, null );
    if (cursor != null && cursor.moveToFirst() ) {
      myNextCId = cursor.getLong(0);
    }
 } catch ( SQLiteDiskIOException e ) { handleDiskIOError( e );
 } finally { if (cursor != null && !cursor.isClosed()) cursor.close(); }
  return cid;
}
项目:topodroid    文件:DataHelper.java   
public boolean renameSurvey( long id, String name, boolean forward )
{
  ContentValues vals = new ContentValues();
  vals.put("name", name );
  try {
    myDB.beginTransaction();
    myDB.update( SURVEY_TABLE, vals, "id=?", new String[]{ Long.toString(id) } );
    myDB.setTransactionSuccessful();
    if ( forward && mListeners != null ) { // synchronized( mListeners )
      mListeners.onUpdateSurveyName( id, name );
    }
  } catch ( SQLiteDiskIOException e )  { handleDiskIOError( e );
  } catch ( SQLiteException e1 )       { logError("survey rename " + name, e1 ); 
  // } catch ( IllegalStateException e2 ) { logError("survey rename", e2 );
  } finally { myDB.endTransaction(); }
  return true;
}
项目:topodroid    文件:DataHelper.java   
public void updateSurveyInfo( long id, String date, String team, double decl, String comment,
                              String init_station, int xsections, boolean forward )
{
  ContentValues vals = new ContentValues();
  vals.put( "day", date );
  vals.put( "team", ((team != null)? team : "") );
  vals.put( "declination", decl );
  vals.put( "comment", ((comment != null)? comment : "") );
  vals.put( "init_station", ((init_station != null)? init_station : "") );
  vals.put( "xsections", xsections );

  try {
    myDB.beginTransaction();
    myDB.update( SURVEY_TABLE, vals, "id=?", new String[]{ Long.toString(id) } );
    myDB.setTransactionSuccessful();
    if ( forward && mListeners != null ) { // synchronized( mListeners )
      mListeners.onUpdateSurveyInfo( id, date, team, decl, comment, init_station, xsections );
    }
  } catch ( SQLiteDiskIOException e )  { handleDiskIOError( e );
  } catch ( SQLiteException e1 )       { logError("survey info", e1 ); 
  // } catch ( IllegalStateException e2 ) { logError("survey info", e2 );
  } finally { myDB.endTransaction(); }
}
项目:topodroid    文件:DataHelper.java   
private boolean updateStatus( String table, long id, long sid, long status )
{
  boolean ret = false;
  ContentValues vals = new ContentValues();
  vals.put( "status", status );
  try {
    myDB.beginTransaction();
    myDB.update( table, vals, WHERE_SID_ID, new String[]{ Long.toString(sid), Long.toString(id) } );
    myDB.setTransactionSuccessful();
    ret = true;
  } catch ( SQLiteDiskIOException e )  {  handleDiskIOError( e );
  } catch (SQLiteException e1 )        { logError(table + " update " + id, e1 ); 
  // } catch ( IllegalStateException e2 ) { logError(table + " update " + id, e2 );
  } finally { myDB.endTransaction(); }
  return ret;
}
项目:topodroid    文件:DataHelper.java   
public String getValue( String key )
{
  if ( myDB == null ) {
    TDLog.Error( "DataHelper::getValue null DB");
    return null;
  }
  if ( key == null || key.length() == 0 ) { // this is not an error
    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;
}
项目:LeanLauncher    文件:WidgetPreviewLoader.java   
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 + "/%"
                        } // args to SELECT query
                );
            } catch (SQLiteDiskIOException ignored) {
            }
            synchronized(sInvalidPackages) {
                sInvalidPackages.remove(packageName);
            }
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}
项目:androidclient    文件:MessagesController.java   
public Uri sendTextMessage(Conversation conv, String text, long inReplyTo) {
    boolean encrypted = MessageUtils.sendEncrypted(mContext, conv.isEncryptionEnabled());

    String msgId = MessageUtils.messageId();
    String userId = conv.isGroupChat() ? conv.getGroupJid() : conv.getRecipient();

    // save to local storage
    Uri newMsg = MessagesProviderClient.newOutgoingMessage(mContext,
            msgId, userId, text, encrypted, inReplyTo);
    if (newMsg != null) {
        // send message!
        if (conv.isGroupChat()) {
            MessageCenterService.sendGroupTextMessage(mContext,
                    conv.getGroupJid(), conv.getGroupSubject(), conv.getGroupPeers(),
                    text, encrypted, ContentUris.parseId(newMsg), msgId, inReplyTo);
        } else {
            MessageCenterService.sendTextMessage(mContext, userId, text,
                    encrypted, ContentUris.parseId(newMsg), msgId, inReplyTo);
        }

        return newMsg;
    } else {
        throw new SQLiteDiskIOException();
    }
}
项目:androidclient    文件:MessagesController.java   
public Uri sendLocationMessage(Conversation conv, String text, double lat, double lon,
    String geoText, String geoStreet) {
    boolean encrypted = MessageUtils.sendEncrypted(mContext, conv.isEncryptionEnabled());

    String msgId = MessageUtils.messageId();
    String userId = conv.isGroupChat() ? conv.getGroupJid() : conv.getRecipient();

    // save to local storage
    Uri newMsg = MessagesProviderClient.newOutgoingMessage(mContext,
            msgId, userId, text, lat, lon, geoText, geoStreet, encrypted);
    if (newMsg != null) {
        // send message!
        if (conv.isGroupChat()) {
            MessageCenterService.sendGroupLocationMessage(mContext,
                    conv.getGroupJid(), conv.getGroupSubject(), conv.getGroupPeers(),
                    text, lat, lon, geoText, geoStreet, encrypted, ContentUris.parseId(newMsg), msgId);
        } else {
            MessageCenterService.sendLocationMessage(mContext, userId, text, lat, lon,
                    geoText, geoStreet, encrypted, ContentUris.parseId(newMsg), msgId);
        }

        return newMsg;
    } else {
        throw new SQLiteDiskIOException();
    }
}
项目:androidclient    文件:MessagesController.java   
public Uri sendBinaryMessage(Conversation conv, Uri uri, String mime, boolean media,
                             Class<? extends MessageComponent<?>> klass) throws IOException {
    String msgId = MessageCenterService.messageId();

    boolean encrypted = MessageUtils.sendEncrypted(mContext, conv.isEncryptionEnabled());
    int compress = 0;
    if (klass == ImageComponent.class) {
        compress = Preferences.getImageCompression(mContext);
    }

    // save to database
    String userId = conv.isGroupChat() ? conv.getGroupJid() : conv.getRecipient();
    Uri newMsg = MessagesProviderClient.newOutgoingMessage(mContext, msgId,
            userId, mime, uri, 0, compress, null, encrypted);

    if (newMsg != null) {
        // prepare message and send (thumbnail, compression -> send)
        MediaService.prepareMessage(mContext, msgId, ContentUris.parseId(newMsg), uri, mime, media, compress);
        return newMsg;
    } else {
        throw new SQLiteDiskIOException();
    }
}
项目:picview-for-android    文件:FileSystemImageCache.java   
/**
 * 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;
  }
}
项目:Picasa-Tagger    文件:FileSystemImageCache.java   
/**
 * 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;
  }
}
项目:vinyl-cast    文件:DatabaseAdapter.java   
@Override
public void onCreate(SQLiteDatabase db)
        throws SQLiteConstraintException, SQLiteDiskIOException,
              SQLiteException {

    db.execSQL(CREATE_TABLE_SEARCH_HISTORY);
    db.execSQL(CREATE_TABLE_RESPONSES);
    db.execSQL(CREATE_INDEX_DATE);
    Log.i(TAG, "Tables created...");

}
项目:vinyl-cast    文件:DatabaseAdapter.java   
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
        throws SQLiteConstraintException, SQLiteDiskIOException,
              SQLiteException {
    Log.i(TAG, "table upgraded");
    db.execSQL("DROP TABLE IF EXISTS "+MUSIC_HISTORY_RESPONSE_TABLE);
    db.execSQL("DROP TABLE IF EXISTS "+MUSIC_HISTORY_TABLE);
    onCreate(db);
}
项目:YuiHatano    文件:ShadowDatabaseUtils.java   
/**
 * Special function for writing an exception result at the header of
 * a parcel, to be used when returning an exception from a transaction.
 * exception will be re-thrown by the function in another process
 *
 * @param reply Parcel to write to
 * @param e     The Exception to be written.
 * @see Parcel#writeNoException
 * @see Parcel#writeException
 */
public static final void writeExceptionToParcel(Parcel reply, Exception e) {
    int     code         = 0;
    boolean logException = true;
    if (e instanceof FileNotFoundException) {
        code = 1;
        logException = false;
    } else if (e instanceof IllegalArgumentException) {
        code = 2;
    } else if (e instanceof UnsupportedOperationException) {
        code = 3;
    } else if (e instanceof SQLiteAbortException) {
        code = 4;
    } else if (e instanceof SQLiteConstraintException) {
        code = 5;
    } else if (e instanceof SQLiteDatabaseCorruptException) {
        code = 6;
    } else if (e instanceof SQLiteFullException) {
        code = 7;
    } else if (e instanceof SQLiteDiskIOException) {
        code = 8;
    } else if (e instanceof SQLiteException) {
        code = 9;
    } else if (e instanceof OperationApplicationException) {
        code = 10;
    } else if (e instanceof OperationCanceledException) {
        code = 11;
        logException = false;
    } else {
        reply.writeException(e);
        Log.e(TAG, "Writing exception to parcel", e);
        return;
    }
    reply.writeInt(code);
    reply.writeString(e.getMessage());

    if (logException) {
        Log.e(TAG, "Writing exception to parcel", e);
    }
}
项目:KBUnitTest    文件:ShadowDatabaseUtils.java   
/**
 * Special function for writing an exception result at the header of
 * a parcel, to be used when returning an exception from a transaction.
 * exception will be re-thrown by the function in another process
 *
 * @param reply Parcel to write to
 * @param e     The Exception to be written.
 * @see Parcel#writeNoException
 * @see Parcel#writeException
 */
public static final void writeExceptionToParcel(Parcel reply, Exception e) {
    int     code         = 0;
    boolean logException = true;
    if (e instanceof FileNotFoundException) {
        code = 1;
        logException = false;
    } else if (e instanceof IllegalArgumentException) {
        code = 2;
    } else if (e instanceof UnsupportedOperationException) {
        code = 3;
    } else if (e instanceof SQLiteAbortException) {
        code = 4;
    } else if (e instanceof SQLiteConstraintException) {
        code = 5;
    } else if (e instanceof SQLiteDatabaseCorruptException) {
        code = 6;
    } else if (e instanceof SQLiteFullException) {
        code = 7;
    } else if (e instanceof SQLiteDiskIOException) {
        code = 8;
    } else if (e instanceof SQLiteException) {
        code = 9;
    } else if (e instanceof OperationApplicationException) {
        code = 10;
    } else if (e instanceof OperationCanceledException) {
        code = 11;
        logException = false;
    } else {
        reply.writeException(e);
        Log.e(TAG, "Writing exception to parcel", e);
        return;
    }
    reply.writeInt(code);
    reply.writeString(e.getMessage());

    if (logException) {
        Log.e(TAG, "Writing exception to parcel", e);
    }
}
项目:sqlite-android    文件:DatabaseErrorHandlerTest.java   
public void testDatabaseIsCorrupt() throws IOException {
    mDatabase.execSQL("create table t (i int);");
    // write junk into the database file
    BufferedWriter writer = new BufferedWriter(new FileWriter(mDatabaseFile.getPath()));
    writer.write("blah");
    writer.close();
    assertTrue(mDatabaseFile.exists());
    // since the database file is now corrupt, doing any sql on this database connection
    // should trigger call to MyDatabaseCorruptionHandler.onCorruption
    try {
        mDatabase.execSQL("select * from t;");
        fail("expected exception");
    } catch (SQLiteDiskIOException e) {
        /**
         * this test used to produce a corrupted db. but with new sqlite it instead reports
         * Disk I/O error. meh..
         * need to figure out how to cause corruption in db
         */
        // expected
        if (mDatabaseFile.exists()) {
            mDatabaseFile.delete();
        }
    } catch (SQLiteException ignored) {

    }
    // database file should be gone
    assertFalse(mDatabaseFile.exists());
    // after corruption handler is called, the database file should be free of
    // database corruption
    SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null,
            new MyDatabaseCorruptionHandler());
    assertTrue(db.isDatabaseIntegrityOk());
}
项目:TurboLauncher    文件:WidgetPreviewLoader.java   
private void clearDb() {
    SQLiteDatabase db = mDb.getWritableDatabase();
    // Delete everything
    try {
        db.delete(CacheDb.TABLE_NAME, null, null);
    } catch (SQLiteDiskIOException e) {
    }
}
项目:TurboLauncher    文件:WidgetPreviewLoader.java   
public static void removeItemFromDb(final CacheDb cacheDb, final String objectName) {
    new AsyncTask<Void, Void, Void>() {
        public Void doInBackground(Void ... args) {
            SQLiteDatabase db = cacheDb.getWritableDatabase();
            try {
                db.delete(CacheDb.TABLE_NAME,
                        CacheDb.COLUMN_NAME + " = ? ", // SELECT query
                        new String[] { objectName }); // args to SELECT query
            } catch (SQLiteDiskIOException e) {
            }
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}