This source file includes following definitions.
- insertImageIntoMediaStore
package org.chromium.base;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import org.chromium.base.CalledByNative;
public class ContentUriTestUtils {
@CalledByNative
private static String insertImageIntoMediaStore(Context context, String path) {
Cursor c = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaStore.Video.VideoColumns._ID },
MediaStore.Images.Media.DATA + " LIKE ?",
new String[] { path },
null);
if (c != null && c.getCount() > 0) {
c.moveToFirst();
int id = c.getInt(0);
return Uri.withAppendedPath(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + id).toString();
}
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, path);
Uri uri = context.getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
return uri.toString();
}
}