CursorLoader throws NullPointerException if argument 'selection' is null
<p>I'm trying to use the loader concept in Android for the first time.</p>

<p>Here is my testing code:</p>

<pre><code>package at.powersoftware.hello.loader;

import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.SimpleCursorAdapter;
import android.util.Log;
import android.view.Menu;
import android.widget.ListView;

public class HelloLoaderActivity extends FragmentActivity implements LoaderManager.LoaderCallbacks&lt;Cursor&gt; {

    static final int LOADER_CONTACTS = 1;   // ID of the loader

    ListView list;
    SimpleCursorAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loaderactivity);

        list = (ListView) findViewById(R.id.listView);

        getSupportLoaderManager().initLoader(LOADER_CONTACTS, null, this);

        String[] from = {Contacts.DISPLAY_NAME, Contacts.TIMES_CONTACTED};
        int[] to = {R.id.tvDisplayName, R.id.tvTimesContacted};

  adapter = new SimpleCursorAdapter(this, R.layout.contactlist3, null, from, to, 0);

        list.setAdapter(adapter);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.loaderactivity, menu);
        return true;
    }

    @Override
    public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {

        String[] projection = {Contacts._ID, Contacts.DISPLAY_NAME, Contacts.TIMES_CONTACTED};
        String selection = null; //"1=1" or even "" works;  
    String[] selectionArgs = null;
        String sortOrder = Contacts.TIMES_CONTACTED + " desc, " + Contacts.DISPLAY_NAME; 

        CursorLoader cl = new CursorLoader(this, Contacts.CONTENT_URI, projection, selection, selectionArgs, sortOrder);

        return cl;

    }

    @Override
    public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor cursor) {

        adapter.swapCursor(cursor);
    }

    @Override
    public void onLoaderReset(Loader&lt;Cursor&gt; arg0) {

        adapter.swapCursor(null);
    }

}
</code></pre>

<p>I want to select all records of the content provider, therefore I specify null for the 'selection' argument. But this gives me the error below.
If I supply a selection criteria like "1=1" or even "" it works perfectly.
Any ideas what the problem could be? - Thanks in advance!</p>

<pre><code>08-01 13:28:06.092: E/AndroidRuntime(1528): FATAL EXCEPTION: main
08-01 13:28:06.092: E/AndroidRuntime(1528): java.lang.RuntimeException: Unable to start activity ComponentInfo{at.powersoftware.hello.loader/at.powersoftware.hello.loader.HelloLoaderActivity}: java.lang.NullPointerException: println needs a message
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.os.Looper.loop(Looper.java:123)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at java.lang.reflect.Method.invokeNative(Native Method)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at java.lang.reflect.Method.invoke(Method.java:507)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at dalvik.system.NativeStart.main(Native Method)
08-01 13:28:06.092: E/AndroidRuntime(1528): Caused by: java.lang.NullPointerException: println needs a message
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.util.Log.println_native(Native Method)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.util.Log.i(Log.java:158)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at at.powersoftware.hello.loader.HelloLoaderActivity.onCreateLoader(HelloLoaderActivity.java:73)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.support.v4.app.LoaderManagerImpl.createLoader(LoaderManager.java:487)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.support.v4.app.LoaderManagerImpl.createAndInstallLoader(LoaderManager.java:496)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.support.v4.app.LoaderManagerImpl.initLoader(LoaderManager.java:550)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at at.powersoftware.hello.loader.HelloLoaderActivity.onCreate(HelloLoaderActivity.java:30)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-01 13:28:06.092: E/AndroidRuntime(1528):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-01 13:28:06.092: E/AndroidRuntime(1528):     ... 11 more
</code></pre>
