Why do I sometimes get a null return, from ContentResolver query?

by sandy8531 » Sun, 08 Mar 2009 09:56:01 GMT

Sponsored Links
 My external sdcard is connected, mounted and functional. I have over
1000 songs on the sdcard, however occasionally this query returns a
null Cursor to me.

Can someone shed some light as to why this happens ? Can I get this is
the underlying table is locked by another thread ? Should I take a
null return from the query to mean a temporary error ?

String[] cols = {

Cursor c = context.getContentResolver().query
Media.IS_MUSIC + " = 1",


Other Threads

1. How can I know date changed? seems android.intent.action.DATE_CHANGED works not properly

   One of my application need to know a new day is coming, that is,
if the clock of phone changed from 23:59 to 00:00, my application will
do some logic. I tried to  use android.intent.action.DATE_CHANGED, but
based on my test, this event only occured when i change the date
mannually, I could not get this action when clock changed from 23:59
to 00:00. Does anybody know why?

This is the defination in AndroidMainfest.xml
   <receiver android:name=".DateBoradcastReceiver"
                <action android:name="android.intent.action.TIME_SET"/

Below is the code in DateBoradcastReceiver class:
     public void onReceive(Context arg0, Intent arg1) {
                        Log.d("PregnancyWidget", "intent= "
                                + arg1);
                String action = arg1.getAction();
                if (action.equals(Intent.ACTION_DATE_CHANGED)||action.equals
                     //business logic is here

Thanks in advance for your help.


2. Custom Drawable (Gradient) based on Theme

I would like to apply a different drawable (or different colors to my
gradient drawable), based on the Theme.  Is this possible?


3. Detecting enter key from virtual keyboard

4. Extend "Edit Contact" view with new field

5. listactivity xml

6. Interpretation

7. UTF-8 encoding problem