title: getting null pointer exception?
body: <p>I am trying to have name of contacts in one array and their types in another array,but can't get through with null pointer exception.here is my code.I have pointed out the line where I am getting null pointer exception.please help..thanks in advance.</p>
  
  <pre><code>package application.test;
  import android.app.Activity;
  import android.content.ContentResolver;
  import android.database.Cursor;
  import android.database.SQLException;
  import android.os.Bundle;
  import android.provider.ContactsContract;
  import android.provider.ContactsContract.CommonDataKinds.Phone;  
  import android.provider.ContactsContract.Contacts.Data;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.ViewGroup.LayoutParams;
  import android.widget.LinearLayout;
  import android.widget.ListView;
  import android.widget.RelativeLayout;
  
  public final class TestActivity extends Activity {
  String[] name;
  String[] phoneType;
  ListView lv;
  ListViewAdapter lva;
  
  
      public static final String TAG = "ContactManager";
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      Log.v(TAG, "Activity State: onCreate()");
      super.onCreate(savedInstanceState);
      LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);        
      LinearLayout mainLayout=new LinearLayout(this);
      mainLayout.setOrientation(LinearLayout.VERTICAL);               
      LayoutInflater layoutInflater = getLayoutInflater();        
      mainLayout.addView(layoutInflater.inflate(R.layout.main,null));
      mainLayout.addView(layoutInflater.inflate(R.layout.extra,null));
  
      this.addContentView(mainLayout, params);
  
        lv = (ListView)findViewById(android.R.id.list);
       lva = new ListViewAdapter(this,name,phoneType); 
      lv.setAdapter(lva);
      testGetContacts();
  }
  
  
  private void testGetContacts() { 
  
          ContentResolver cr = getContentResolver();
  
          String[] projection = new String[] { Data._ID,
                  ContactsContract.Contacts.DISPLAY_NAME, Phone.TYPE}; 
  
          Cursor cur = cr.query(ContactsContract.Data.CONTENT_URI,
                  projection, null, null, null); 
  
  
          if (cur != null &amp;&amp; cur.moveToFirst()) { 
  
          try {
  
              int indexID =  cur.getColumnIndexOrThrow(ContactsContract.Contacts._ID);
              int indexName = cur.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME);
               int indexPhoneType = cur.getColumnIndexOrThrow(Phone.TYPE);
  
            while (cur.moveToNext()) {
               int  i=1;
                String id = cur.getString(indexID);    
   //HERE LIES NULL POINTER EXCEPTION   name[i] = cur.getString(indexName);  
   //HERE TOO              phoneType[i] =  cur.getString(indexPhoneType);
  
               i++;
  
  
                System.out.println(id + "\n");
                System.out.println(name + "\n");
                System.out.println(phoneType + "\n");
  
  
            }
  
  
          } catch (SQLException sqle) {
             //handling exception       
          } finally { 
           if (!cur.isClosed()) {
               cur.close();
           }     
       }
  
          }
  
  }
  }
  </code></pre>