List array error
<p>My project seems to have no errors but when i access my activity it force closes and this appears in my logcat. Whats wrong with my codes?</p>

<pre><code>03-06 14:03:36.994: E/AndroidRuntime(20120): FATAL EXCEPTION: main
03-06 14:03:36.994: E/AndroidRuntime(20120): java.lang.RuntimeException: Unable to start activity ComponentInfo{me.mojica.caloriewatch/me.mojica.caloriewatch.Search}: java.lang.NullPointerException
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.os.Looper.loop(Looper.java:123)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.app.ActivityThread.main(ActivityThread.java:4627)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at java.lang.reflect.Method.invokeNative(Native Method) 
03-06 14:03:36.994: E/AndroidRuntime(20120):    at java.lang.reflect.Method.invoke(Method.java:521)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at dalvik.system.NativeStart.main(Native Method)
03-06 14:03:36.994: E/AndroidRuntime(20120): Caused by: java.lang.NullPointerException
03-06 14:03:36.994: E/AndroidRuntime(20120):    at java.util.Arrays$ArrayList.&lt;init&gt;(Arrays.java:49)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at java.util.Arrays.asList(Arrays.java:171)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.widget.ArrayAdapter.&lt;init&gt;(ArrayAdapter.java:125)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at me.mojica.caloriewatch.Search.onCreate(Search.java:117)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-06 14:03:36.994: E/AndroidRuntime(20120):    at  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-06 14:03:36.994: E/AndroidRuntime(20120):    ... 11 more
</code></pre>

<p>This is my Activity, when i try to open this, the force close window appears immediately</p>

<pre><code>private String[] listview_array;
private ArrayList&lt;String&gt; array_sort= new ArrayList&lt;String&gt;();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.search);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

  listContent1  = (ListView)findViewById(R.id.lFoodlist1);
  search= (EditText) findViewById(R.id.eFsearch);
  food= (EditText) findViewById(R.id.editText1);
  calories= (EditText) findViewById(R.id.editText2);  
  FSearch=(Button) findViewById(R.id.bFsearch);
  result=(TextView)findViewById(R.id.textView3);




  mySQLiteAdapter = new SQLiteAdapter(this);
  mySQLiteAdapter.openToRead();

  Cursor cursor = mySQLiteAdapter.queueAll();
  startManagingCursor(cursor);

  String[] from = new String[]{SQLiteAdapter.KEY_FOODNAME,SQLiteAdapter.KEY_CALORIES};
  int[] to = new int[]{R.id.tv1, R.id.tv2};

  SimpleCursorAdapter cursorAdapter =
   new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);

  //listContent1.setAdapter(cursorAdapter);
  listContent1.setOnItemClickListener(listContentOnItemClickListener); 
  mySQLiteAdapter.close();


  listContent1.setAdapter(new ArrayAdapter&lt;String&gt;(this,
          android.R.layout.simple_list_item_1, listview_array));

  search.addTextChangedListener(new TextWatcher() {

       public void afterTextChanged(Editable s) {

       }

       public void beforeTextChanged(CharSequence s, int start, int count,
         int after) {

       }

       public void onTextChanged(CharSequence s, int start, int before,
         int count) {

        textlength = search.getText().length();
        array_sort.clear();


        for (int i = 0; i &lt; listview_array.length; i++)
          {
             if (textlength &lt;= listview_array[i].length())
             {
             if(search.getText().toString().equalsIgnoreCase(
             (String)
             listview_array[i].subSequence(0,
             textlength)))
             {
              array_sort.add(listview_array[i]);
                 }
              }
       }
             listContent1.setAdapter(new ArrayAdapter&lt;String&gt;
             (Search.this,
             android.R.layout.simple_list_item_1, array_sort));
             }

             });

     }

 }
</code></pre>

<p>adapter</p>

<pre><code>public String[] qall(){
    Cursor cursor = null;
    String[] columns = new String[]{KEY_ID, KEY_FOODNAME, KEY_CALORIES};
    String[] listview_array = null;
    try{
         cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns,
                null, null, null, null, null);

        if(cursor!=null &amp;&amp; cursor.getCount()&gt;0 &amp;&amp; cursor.moveToFirst()){
            listview_array=new String[cursor.getCount()];

            int foodName = cursor.getColumnIndex(KEY_FOODNAME );
            int keyColories = cursor.getColumnIndex(KEY_CALORIES );
            int l=0;
            boolean moveToNext = cursor.moveToFirst();
            do{
            listview_array[l]=cursor.getString(foodName) + "                              " +
                    cursor.getString(keyColories);
               l++;
            }while(cursor.moveToNext());
        }
    }catch(Exception e){
        Log.e(APP_NAME, "An error occurred while searching for "+search+": "+e.toString(), e);
    }finally{
        if(cursor!=null &amp;&amp; !cursor.isClosed()){
            cursor.close();
        }
    }
    return listview_array;

}
</code></pre>

<p>my whole code. help please</p>

<p>LATEST ERRORS</p>

<pre><code>03-06 15:07:08.316: E/AndroidRuntime(23106): FATAL EXCEPTION: main
03-06 15:07:08.316: E/AndroidRuntime(23106): java.lang.RuntimeException: Unable to start activity ComponentInfo{me.mojica.caloriewatch/me.mojica.caloriewatch.Search}: java.lang.NullPointerException
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.os.Looper.loop(Looper.java:123)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.app.ActivityThread.main(ActivityThread.java:4627)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at java.lang.reflect.Method.invokeNative(Native Method)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at java.lang.reflect.Method.invoke(Method.java:521)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at dalvik.system.NativeStart.main(Native Method)
03-06 15:07:08.316: E/AndroidRuntime(23106): Caused by: java.lang.NullPointerException
03-06 15:07:08.316: E/AndroidRuntime(23106):    at java.util.Arrays$ArrayList.&lt;init&gt;(Arrays.java:49)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at java.util.Arrays.asList(Arrays.java:171)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.widget.ArrayAdapter.&lt;init&gt;(ArrayAdapter.java:125)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at me.mojica.caloriewatch.Search.onCreate(Search.java:117)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-06 15:07:08.316: E/AndroidRuntime(23106):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-06 15:07:08.316: E/AndroidRuntime(23106):    ... 11 more
</code></pre>
