I want to pick an image from gallery and then get the path of the image on SD card
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), 1);
then Activity result as
public void onActivityResult(int requestCode, int resultCode, Intent data) {
String tempImage = null;
File f = null ;
if (resultCode == RESULT_OK && requestCode == 1 && data!=null)
{
Uri selectedImageUri = data.getData(); // always null Uri WHY?
selectedImagePath = getPath(selectedImageUri);
if(selectedImagePath!=null)
{
........
and the getPath method
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
The problem is Uri selectedImageUri = data.getData();
giving the null value. Yesterday it was working fine.
even intent
is not null.
I tried cleaning the project but the problem still remain same.
Thanks in Advance!!
*UPDATE SOLUTION *
solution is HERE