示例#1
0
  public Pair<String, List<Object>> getTableInsertData(Persistable p) {
    String built = "INSERT INTO " + scrubName(name) + " (";
    HashMap<String, Object> contentValues = UserDatabaseHelper.getContentValues(p);

    ArrayList<Object> params = new ArrayList<Object>();

    for (int i = 0; i < rawCols.size(); ++i) {
      built += rawCols.elementAt(i);
      if (i < rawCols.size() - 1) {
        built += ", ";
      }
    }

    built += ") VALUES (";

    for (int i = 0; i < rawCols.size(); ++i) {
      Object currentValue = contentValues.get(rawCols.elementAt(i));
      built += "?";
      params.add(currentValue);
      if (i < rawCols.size() - 1) {
        built += ", ";
      }
    }

    built += ");";

    return new Pair(built, params);
  }
示例#2
0
  public String getTableInsertString(Persistable p) {
    String built = "INSERT INTO " + scrubName(name) + " (";
    HashMap<String, Object> contentValues = UserDatabaseHelper.getContentValues(p);

    for (int i = 0; i < rawCols.size(); ++i) {
      built += rawCols.elementAt(i);
      if (i < rawCols.size() - 1) {
        built += ", ";
      }
    }

    byte[] blob = toBlob(p);

    built += ") VALUES (";
    for (int i = 0; i < rawCols.size(); ++i) {
      Object currentValue = contentValues.get(rawCols.elementAt(i));
      if (currentValue instanceof String) {
        built += "`" + contentValues.get(rawCols.elementAt(i)) + "`";
      } else {
        built += contentValues.get(rawCols.elementAt(i));
      }
      if (i < rawCols.size() - 1) {
        built += ", ";
      }
    }
    built += ");";

    return built;
  }