I am getting error if i am sharing image to my app from third party.
Like share image from whatsApp, InstagramDownloader, etc.
I am getting uri and changing it to path.
If i am sharing video from gallery it's working fine but, when i am sharing from third party app it's crashing.
public String getpath(Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Video.Media.DATA};
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
Please if anyone have any suggestion help me..