android browse images failure delivering result error
<p>I want to browse an image and then display the path of my image in my edit text.It 's working until i press the image from which i want the paath then i get next error:</p>

<pre><code>    12-24 14:18:58.377: E/AndroidRuntime(5606): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/72 }} to activity {ianco.test.andrei/ianco.test.andrei.BrowsePicture}: java.lang.NullPointerException
    12-24 14:19:40.537: E/AndroidRuntime(5892): FATAL EXCEPTION: main
   12-24 14:19:40.537: E/AndroidRuntime(5892): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/73 }} to activity {ianco.test.andrei/ianco.test.andrei.BrowsePicture}: java.lang.NullPointerException                                   
      12-24 14:19:40.537: E/AndroidRuntime(5892):   at android.app.ActivityThread.deliverResults(ActivityThread.java:2553)
      12-24 14:19:40.537: E/AndroidRuntime(5892):   at android.app.ActivityThread.handleSendResult(ActivityThread.java:2595)
      12-24 14:19:40.537: E/AndroidRuntime(5892):   at android.app.ActivityThread.access$2000(ActivityThread.java:121)
     12-24 14:19:40.537: E/AndroidRuntime(5892):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
    12-24 14:19:40.537: E/AndroidRuntime(5892):     at android.os.Handler.dispatchMessage(Handler.java:99)
    12-24 14:19:40.537: E/AndroidRuntime(5892):     at android.os.Looper.loop(Looper.java:130)
    12-24 14:19:40.537: E/AndroidRuntime(5892):     at android.app.ActivityThread.main(ActivityThread.java:3701)
    12-24 14:19:40.537: E/AndroidRuntime(5892):     at java.lang.reflect.Method.invokeNative(Native Method)
    12-24 14:19:40.537: E/AndroidRuntime(5892):     at java.lang.reflect.Method.invoke(Method.java:507)
    12-24 14:19:40.537: E/AndroidRuntime(5892):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    12-24 14:19:40.537: E/AndroidRuntime(5892):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
   12-24 14:19:40.537: E/AndroidRuntime(5892):  at dalvik.system.NativeStart.main(Native Method)
   12-24 14:19:40.537: E/AndroidRuntime(5892): Caused by: java.lang.NullPointerException
  12-24 14:19:40.537: E/AndroidRuntime(5892):   at ianco.test.andrei.BrowsePicture.onActivityResult(BrowsePicture.java:57)
  12-24 14:19:40.537: E/AndroidRuntime(5892):   at android.app.Activity.dispatchActivityResult(Activity.java:3908)
  12-24 14:19:40.537: E/AndroidRuntime(5892):   at android.app.ActivityThread.deliverResults(ActivityThread.java:2549)
  12-24 14:19:40.537: E/AndroidRuntime(5892):   ... 11 more
</code></pre>

<p>my .java is:`package ianco.test.andrei;</p>

<pre><code>              import android.app.Activity;
              import android.content.Intent;
               import android.database.Cursor;
               import android.net.Uri;
               import android.os.Bundle;
               import android.provider.MediaStore;
                import android.view.View;
               import android.view.View.OnClickListener;
              import android.widget.Button;
               import android.widget.EditText;
               import android.util.Log;
             public class BrowsePicture extends Activity {

//YOU CAN EDIT THIS TO WHATEVER YOU WANT
          private static final int SELECT_PICTURE = 1;

           private String filePath;
           public EditText myText;

           public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

   Button sButton = (Button) findViewById(R.id.button1);
   sButton.setOnClickListener(new OnClickListener() {

               public void onClick(View arg0) {

            // in onCreate or any event where your want the user to
            // select a file
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent,
                    "Select Picture"), SELECT_PICTURE);
        }
    });
}

//UPDATED
                   public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == SELECT_PICTURE) {


            Uri selectedImage = data.getData();
            String[] filePathColumn = {MediaStore.Images.Media.DATA};

            Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            filePath = cursor.getString(columnIndex);
            Log.i("the path of image is", filePath);
            myText.setText(filePath);
            cursor.close();
        }

    }   }
}`
</code></pre>
