/**
  * Utility method to run the pre-compiled query and return the value in the first column of the
  * first row.
  */
 public static String stringForQuery(SQLiteStatement prog, String[] selectionArgs) {
   if (selectionArgs != null) {
     int size = selectionArgs.length;
     for (int i = 0; i < size; i++) {
       bindObjectToProgram(prog, i + 1, selectionArgs[i]);
     }
   }
   String value = prog.simpleQueryForString();
   return value;
 }
 /**
  * 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;
   }
 }