java null pointer exception when trying to get path of an image
<p>I am working on a contact list application and i am getting an error when i try to get the path of my image in my edit text:</p>

<pre><code>12-27 18:12:37.909: E/AndroidRuntime(2620): Caused by: java.lang.NullPointerException
12-27 18:12:37.909: E/AndroidRuntime(2620):     at org.example.dbcontactconsole.ContactDetails.onCreate(ContactDetails.java:54)
12-27 18:12:37.909: E/AndroidRuntime(2620):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-27 18:12:37.909: E/AndroidRuntime(2620):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
</code></pre>

<p>ContactDetails.java source is:</p>

<pre><code>package org.example.dbcontactconsole;

import android.app.Activity;
import android.app.AlertDialog;                                                                            
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;

public class ContactDetails extends Activity{
    private Button cancelButton;
    private Button saveContactButton;
    private static EditText poza;
    private static final int SELECT_PICTURE = 1;
    private static EditText nameField; 
    private static EditText mobilePhoneField;
    private static EditText emailField;
    private static Uri currImageURI;

    private static String operationType;
    static final int RESULT_MODIFY_USER = 2;

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contactdetails);
         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);
              }
          });
        Bundle incomingActionType = getIntent().getExtras();
        operationType = incomingActionType.getString("mod_type");

        if (operationType.equals("addPerson")){

            nameField = (EditText) findViewById(R.id.contactName); 
            mobilePhoneField = (EditText) findViewById(R.id.contactmobile);
            emailField = (EditText) findViewById(R.id.contactemail);
            poza=(EditText) findViewById(R.id.editText1);
            poza.setText(currImageURI.toString());
        }

        else if (operationType.equals("modifyPerson")){

            String modifyFirstName = incomingActionType.getString("cFirstName");
            nameField = (EditText) findViewById(R.id.contactName);
            nameField.setText(modifyFirstName);


            String modifyPhoneNumber = incomingActionType.getString("cMobilePhone");
            mobilePhoneField = (EditText) findViewById(R.id.contactmobile);
            mobilePhoneField.setText(modifyPhoneNumber);

            String modifyEmail = incomingActionType.getString("cEmail");
            emailField = (EditText) findViewById(R.id.contactemail);
            emailField.setText(modifyEmail);    
        }


    cancelButton = (Button) findViewById(R.id.cancelcontactbutton);
    saveContactButton = (Button) findViewById(R.id.savecontactbutton);

    saveContactButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Intent resultIntent = new Intent();
            Bundle contactData = new Bundle();

                if (nameField.getText().toString().length() == 0){
                    new AlertDialog.Builder(ContactDetails.this).setTitle("Error").setMessage("First name field cannot be empty!").setNeutralButton("Close", null).show();
                } else if (mobilePhoneField.getText().toString().length() == 0){
                    new AlertDialog.Builder(ContactDetails.this).setTitle("Error").setMessage("Mobile Phone field cannot be empty!").setNeutralButton("Close", null).show();
                } else if (emailField.getText().toString().length() == 0){
                    new AlertDialog.Builder(ContactDetails.this).setTitle("Error").setMessage("Email field cannot be empty!").setNeutralButton("Close", null).show();
                } else{
                    contactData.putString("contactFirstName", nameField.getText().toString());
                    contactData.putString("contactMobilePhone", mobilePhoneField.getText().toString());
                    contactData.putString("contactEmail", emailField.getText().toString());

                    resultIntent.putExtra("contactData", contactData);

                    if (operationType.equals("addPerson")){
                        setResult(RESULT_FIRST_USER, resultIntent);
                    }else if (operationType.equals("modifyPerson")){
                        setResult(RESULT_MODIFY_USER, resultIntent);
                    }               
                    finish();
                }
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener(){


        public void onClick(View v) {
            Intent resultIntent = new Intent();
            setResult(RESULT_CANCELED, resultIntent);
            finish();


        }
    });

    }
    public void onActivityResult(int requestCode, int resultCode, Intent data) {  
           if (resultCode == RESULT_OK) {
               if (requestCode == 1) {
                   // currImageURI is the global variable I'm using to hold the content:// URI of the image
                    currImageURI = data.getData();
                   getRealPathFromURI(currImageURI);

               }
             }
           }


        public String getRealPathFromURI(Uri currImageURI) {
           // can post image
           String [] proj={MediaStore.Images.Media.DATA};
           Cursor cursor = managedQuery( currImageURI,
                   proj, // Which columns to return
                   null,       // WHERE clause; which rows to return (all rows)
                   null,       // WHERE clause selection arguments (none)
                   null); // Order-by clause (ascending by name)
           int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
           cursor.moveToFirst();


              poza=(EditText)findViewById(R.id.editText1);
               poza.setText(currImageURI.toString());
              return cursor.getString(column_index);

        }
  }
</code></pre>

<p>line 54 is:<code>poza.setText(currImageURI.toString());</code>
I think that the error appears because currimageURI has no value, but i made the onActivityResult method.  Can you help me please?</p>
