Converting android image URI -
i getting below type of uri:
/mnt/sdcard/pictures/ww/ww_1360248819300.jpg
how convert above type of uri below uri:
content://media/external/images/media/12
please help thanks
public static uri getimagecontenturi(context context, file imagefile) { string filepath = imagefile.getabsolutepath(); cursor cursor = context.getcontentresolver().query( mediastore.images.media.external_content_uri, new string[] { mediastore.images.media._id }, mediastore.images.media.data + "=? ", new string[] { filepath }, null); if (cursor != null && cursor.movetofirst()) { int id = cursor.getint(cursor .getcolumnindex(mediastore.mediacolumns._id)); uri baseuri = uri.parse("content://media/external/images/media"); homecoming uri.withappendedpath(baseuri, "" + id); } else { if (imagefile.exists()) { contentvalues values = new contentvalues(); values.put(mediastore.images.media.data, filepath); homecoming context.getcontentresolver().insert( mediastore.images.media.external_content_uri, values); } else { homecoming null; } } }
android uri
No comments:
Post a Comment