Example #1
0
  // Get a ContentValues object for the given photo data
  public static ContentValues getContentValuesForData(
      String title,
      long date,
      Location location,
      int orientation,
      long jpegLength,
      String path,
      int width,
      int height,
      String mimeType) {

    File file = new File(path);
    long dateModifiedSeconds = TimeUnit.MILLISECONDS.toSeconds(file.lastModified());

    ContentValues values = new ContentValues(11);
    values.put(ImageColumns.TITLE, title);
    values.put(ImageColumns.DISPLAY_NAME, title + JPEG_POSTFIX);
    values.put(ImageColumns.DATE_TAKEN, date);
    values.put(ImageColumns.MIME_TYPE, mimeType);
    values.put(ImageColumns.DATE_MODIFIED, dateModifiedSeconds);
    // Clockwise rotation in degrees. 0, 90, 180, or 270.
    values.put(ImageColumns.ORIENTATION, orientation);
    values.put(ImageColumns.DATA, path);
    values.put(ImageColumns.SIZE, jpegLength);

    setImageSize(values, width, height);

    if (location != null) {
      values.put(ImageColumns.LATITUDE, location.getLatitude());
      values.put(ImageColumns.LONGITUDE, location.getLongitude());
    }
    return values;
  }