/** SQL-escape a string. */
  public static String sqlEscapeString(String value) {
    StringBuilder escaper = new StringBuilder();

    DatabaseUtils.appendEscapedSQLString(escaper, value);

    return escaper.toString();
  }
 public static void readExceptionWithFileNotFoundExceptionFromParcel(Parcel reply)
     throws FileNotFoundException {
   int code = reply.readInt();
   if (code == 0) return;
   String msg = reply.readString();
   if (code == 1) {
     throw new FileNotFoundException(msg);
   } else {
     DatabaseUtils.readExceptionFromParcel(reply, msg, code);
   }
 }
 public static void readExceptionWithOperationApplicationExceptionFromParcel(Parcel reply)
     throws OperationApplicationException {
   int code = reply.readInt();
   if (code == 0) return;
   String msg = reply.readString();
   if (code == 10) {
     throw new OperationApplicationException(msg);
   } else {
     DatabaseUtils.readExceptionFromParcel(reply, msg, code);
   }
 }
 /**
  * Performs an insert, adding a new row with the given values.
  *
  * @param values the set of values with which to populate the new row
  * @param allowReplace if true, the statement does "INSERT OR REPLACE" instead of "INSERT",
  *     silently deleting any previously existing rows that would cause a conflict
  * @return the row ID of the newly inserted row, or -1 if an error occurred
  */
 private synchronized long insertInternal(ContentValues values, boolean allowReplace) {
   try {
     SQLiteStatement stmt = getStatement(allowReplace);
     stmt.clearBindings();
     if (LOCAL_LOGV) Log.v(TAG, "--- inserting in table " + mTableName);
     for (Map.Entry<String, Object> e : values.valueSet()) {
       final String key = e.getKey();
       int i = getColumnIndex(key);
       DatabaseUtils.bindObjectToProgram(stmt, i, e.getValue());
       if (LOCAL_LOGV) {
         Log.v(TAG, "binding " + e.getValue() + " to column " + i + " (" + key + ")");
       }
     }
     return stmt.executeInsert();
   } catch (SQLException e) {
     Log.e(TAG, "Error inserting " + values + " into table  " + mTableName, e);
     return -1;
   }
 }
 /**
  * Special function for reading an exception result from the header of a parcel, to be used after
  * receiving the result of a transaction. This will throw the exception for you if it had been
  * written to the Parcel, otherwise return and let you read the normal result data from the
  * Parcel.
  *
  * @param reply Parcel to read from
  * @see Parcel#writeNoException
  * @see Parcel#readException
  */
 public static final void readExceptionFromParcel(Parcel reply) {
   int code = reply.readInt();
   if (code == 0) return;
   String msg = reply.readString();
   DatabaseUtils.readExceptionFromParcel(reply, msg, code);
 }