Code example for ContentResolver

Methods: insert

    // We also insert hint values for the WIDTH and HEIGHT fields to give 
    // correct aspect ratio before the real values are updated in updateImage(). 
    public static Uri newImage(ContentResolver resolver, String title,
            long date, int width, int height) {
        String path = generateFilepath(title);
        // Insert into MediaStore. 
        ContentValues values = new ContentValues(4);
        values.put(ImageColumns.DATE_TAKEN, date);
        values.put(ImageColumns.DATA, path);
        setImageSize(values, width, height);
        Uri uri = null;
        try { 
            uri = resolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
        } catch (Throwable th)  {
            // This can happen when the external volume is already mounted, but 
            // MediaScanner has not notify MediaProvider to add that volume.