Codota Logo
SQLiteException
Code IndexAdd Codota to your IDE (free)

How to use
SQLiteException
in
android.database.sqlite

Best Java code snippets using android.database.sqlite.SQLiteException (Showing top 20 results out of 423)

  • Common ways to obtain SQLiteException
private void myMethod () {
SQLiteException s =
  • Codota IconString str;new SQLiteException(str)
  • Codota Iconnew android.database.sqlite.SQLiteException("unknown type: " + value.type)
  • Smart code suggestions by Codota
}
origin: robolectric/robolectric

String executeForString(final long connectionPtr, final long statementPtr) {
 return executeStatementOperation(connectionPtr, statementPtr, "execute for string", new StatementOperation<String>() {
  @Override
  public String call(final SQLiteStatement statement) throws Exception {
   if (!statement.step()) {
    throw new SQLiteException(SQLiteConstants.SQLITE_DONE, "No rows returned from query");
   }
   return statement.columnString(0);
  }
 });
}
origin: k9mail/k-9

  public static void addFlaggedCountColumn(SQLiteDatabase db) {
    try {
      db.execSQL("ALTER TABLE folders ADD flagged_count INTEGER default 0");
    } catch (SQLiteException e) {
      if (!e.getMessage().startsWith("duplicate column name: flagged_count")) {
        throw e;
      }
    }
  }
}
origin: k9mail/k-9

  public static void addDeletedColumn(SQLiteDatabase db) {
    try {
      db.execSQL("ALTER TABLE messages ADD deleted INTEGER default 0");
    } catch (SQLiteException e) {
      if (!e.toString().startsWith("duplicate column name: deleted")) {
        throw e;
      }
    }
  }
}
origin: weexteam/weex-hackernews

synchronized void ensureDatabase() {
  if (mDb != null && mDb.isOpen()) {
    return;
  }
  // Sometimes retrieving the database fails. We do 2 retries: first without database deletion
  // and then with deletion.
  for (int tries = 0; tries < 2; tries++) {
    try {
      if (tries > 0) {
        //delete db and recreate
        deleteDB();
      }
      mDb = getWritableDatabase();
      break;
    } catch (SQLiteException e) {
      e.printStackTrace();
    }
    // Wait before retrying.
    try {
      Thread.sleep(SLEEP_TIME_MS);
    } catch (InterruptedException ie) {
      Thread.currentThread().interrupt();
    }
  }
  if(mDb == null){
    return;
  }
  createTableIfNotExists(mDb);
  mDb.setMaximumSize(mMaximumDatabaseSize);
}
origin: stackoverflow.com

 private boolean checkDataBase(){

  SQLiteDatabase checkDB = null;

  try{
    String myPath = DB_PATH + DB_NAME;
    checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);
    long result =  DatabaseUtils.longForQuery(checkDB,"SELECT count() FROM sqlite_master WHERE type='table' AND name='table_name'",null);
    if(result == 0)
      checkDB = null;

  }catch(SQLiteException e){

    Log.e("", e.getLocalizedMessage()+e.getMessage()+e.getCause()+
        Arrays.toString(e.getStackTrace()));

  }

  if(checkDB != null){

    checkDB.close();

  }
 return checkDB != null ? true : false;
}
origin: net.sf.mardao/mardao-android

protected Long updateByCore(final ContentValues entity, final SQLiteDatabase dbCon) {
  try {
    final Long id = entity.getAsLong(getPrimaryKeyColumnName());
    String whereArgs[] = {id.toString()};
    debug("updateByCore %s %s", getTableName(), entity);
    dbCon.update(getTableName(), entity, "_id = ?", whereArgs);
    return id;
  }
  catch (SQLiteException e2) {
    error("SQLiteException %s: %s", e2.getMessage(), e2.toString());
    return -1L;
  }
}
origin: ZhuoKeTeam/QPM

public SQLiteDatabase openDB(File file) {
  if (file == null || !file.exists()) {
    return null;
  }
  try {
    return SQLiteDatabase.openDatabase(file.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE);
  } catch (SQLiteException e) {
    e.printStackTrace();
    return null;
  }
}
origin: robolectric/robolectric

long executeForLong(final long connectionPtr, final long statementPtr) {
 return executeStatementOperation(connectionPtr, statementPtr, "execute for long", new StatementOperation<Long>() {
  @Override
  public Long call(final SQLiteStatement statement) throws Exception {
   if (!statement.step()) {
    throw new SQLiteException(SQLiteConstants.SQLITE_DONE, "No rows returned from query");
   }
   return statement.columnLong(0);
  }
 });
}
origin: k9mail/k-9

  public static void addMessagesThreadingColumns(SQLiteDatabase db) {
    try {
      db.execSQL("ALTER TABLE messages ADD thread_root INTEGER");
      db.execSQL("ALTER TABLE messages ADD thread_parent INTEGER");
      db.execSQL("ALTER TABLE messages ADD normalized_subject_hash INTEGER");
      db.execSQL("ALTER TABLE messages ADD empty INTEGER");
    } catch (SQLiteException e) {
      if (!e.getMessage().startsWith("duplicate column name:")) {
        throw e;
      }
    }
  }
}
origin: fg607/RelaxFinger

@Override
protected Void doInBackground(Void... voids) {
  try {
    shortcutList = AppUtils.getShortcuts();
  } catch (SecurityException e) {
    e.printStackTrace();
  } catch (SQLiteException e) {
    e.printStackTrace();
    shortcutList = new ArrayList<ShortcutInfo>();
  }
  return null;
}
origin: k9mail/k-9

  public static void addPreviewColumn(SQLiteDatabase db) {
    try {
      db.execSQL("ALTER TABLE messages ADD preview TEXT");
    } catch (SQLiteException e) {
      if (!e.toString().startsWith("duplicate column name: preview")) {
        throw e;
      }
    }
  }
}
origin: robolectric/robolectric

private static Number nativeGetNumber(long windowPtr, int row, int column) {
 Value value = WINDOW_DATA.get(windowPtr).value(row, column);
 switch (value.type) {
  case Cursor.FIELD_TYPE_NULL:
  case SQLiteConstants.SQLITE_NULL:
   return 0;
  case Cursor.FIELD_TYPE_INTEGER:
  case Cursor.FIELD_TYPE_FLOAT:
   return (Number) value.value;
  case Cursor.FIELD_TYPE_STRING: {
   try {
    return Double.parseDouble((String) value.value);
   } catch (NumberFormatException e) {
    return 0;
   }
  }
  case Cursor.FIELD_TYPE_BLOB:
   throw new android.database.sqlite.SQLiteException("could not convert "+value);
  default:
   throw new android.database.sqlite.SQLiteException("unknown type: "+value.type);
 }
}
origin: k9mail/k-9

public static void db41FoldersAddClassColumns(SQLiteDatabase db) {
  try {
    db.execSQL("ALTER TABLE folders ADD integrate INTEGER");
    db.execSQL("ALTER TABLE folders ADD top_group INTEGER");
    db.execSQL("ALTER TABLE folders ADD poll_class TEXT");
    db.execSQL("ALTER TABLE folders ADD push_class TEXT");
    db.execSQL("ALTER TABLE folders ADD display_class TEXT");
  } catch (SQLiteException e) {
    if (!e.getMessage().startsWith("duplicate column name:")) {
      throw e;
    }
  }
}
origin: myxh/CoolShopping

/**
 * 检查数据库是否存在
 * @return
 */
public boolean checkDataBase() {
  SQLiteDatabase checkDB = null;
  String dbPath = DB_PATH + DB_NAME;
  try {
    checkDB = SQLiteDatabase.openDatabase(dbPath,null,SQLiteDatabase.OPEN_READONLY);
  } catch (SQLiteException e) {
    e.printStackTrace();
  } finally {
    if (checkDB != null) {
      checkDB.close();
    }
  }
  return checkDB!=null ? true : false;
}
origin: facebook/stetho

@ChromeDevtoolsMethod
public JsonRpcResult getDatabaseTableNames(JsonRpcPeer peer, JSONObject params)
  throws JsonRpcException {
 GetDatabaseTableNamesRequest request = mObjectMapper.convertValue(params,
   GetDatabaseTableNamesRequest.class);
 String databaseId = request.databaseId;
 DatabaseDescriptorHolder holder =
   mPeerListener.getDatabaseDescriptorHolder(databaseId);
 try {
  GetDatabaseTableNamesResponse response = new GetDatabaseTableNamesResponse();
  response.tableNames = holder.driver.getTableNames(holder.descriptor);
  return response;
 } catch (SQLiteException e) {
  throw new JsonRpcException(
    new JsonRpcError(
      JsonRpcError.ErrorCode.INVALID_REQUEST,
      e.toString(),
      null /* data */));
 }
}
origin: robolectric/robolectric

@Implementation(minSdk = LOLLIPOP)
protected static String nativeGetString(long windowPtr, int row, int column) {
 Value val = WINDOW_DATA.get(windowPtr).value(row, column);
 if (val.type == Cursor.FIELD_TYPE_BLOB) {
  throw new android.database.sqlite.SQLiteException("Getting string when column is blob. Row " + row + ", col " + column);
 }
 Object value = val.value;
 return value == null ? null : String.valueOf(value);
}
origin: k9mail/k-9

  public static void changeThreadingIndexes(SQLiteDatabase db) {
    try {
      db.execSQL("DROP INDEX IF EXISTS msg_empty");
      db.execSQL("CREATE INDEX IF NOT EXISTS msg_empty ON messages (empty)");

      db.execSQL("DROP INDEX IF EXISTS msg_thread_root");
      db.execSQL("CREATE INDEX IF NOT EXISTS msg_thread_root ON messages (thread_root)");

      db.execSQL("DROP INDEX IF EXISTS msg_thread_parent");
      db.execSQL("CREATE INDEX IF NOT EXISTS msg_thread_parent ON messages (thread_parent)");
    } catch (SQLiteException e) {
      if (!e.getMessage().startsWith("duplicate column name:")) {
        throw e;
      }
    }
  }
}
origin: lime-ime/limeime

  e.printStackTrace();
  db.execSQL("create index 'related_idx_pword' on related (pword)");
}catch (SQLiteException e){
  e.printStackTrace();
  db.execSQL("create index 'related_idx_cword' on related (cword)");
}catch (SQLiteException e){
  e.printStackTrace();
origin: openbmap/radiocells-scanner-android

Log.e(TAG, "Error reading from catalog: " + e.toString());
origin: robolectric/robolectric

@Implementation(minSdk = LOLLIPOP)
protected static byte[] nativeGetBlob(long windowPtr, int row, int column) {
 Value value = WINDOW_DATA.get(windowPtr).value(row, column);
 switch (value.type) {
  case Cursor.FIELD_TYPE_NULL:
   return null;
  case Cursor.FIELD_TYPE_BLOB:
   // This matches Android's behavior, which does not match the SQLite spec
   byte[] blob = (byte[])value.value;
   return blob == null ? new byte[]{} : blob;
  case Cursor.FIELD_TYPE_STRING:
   return ((String)value.value).getBytes(UTF_8);
  default:
   throw new android.database.sqlite.SQLiteException("Getting blob when column is non-blob. Row " + row + ", col " + column);
 }
}
android.database.sqliteSQLiteException

Most used methods

  • <init>
  • getMessage
  • printStackTrace
  • toString
  • getCause
  • getLocalizedMessage
  • getStackTrace

Popular in Java

  • Making http requests using okhttp
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • Kernel (java.awt.image)
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • JOptionPane (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now