uri - why sometime i get the cursor null or count equal to zero -


my apliction works fine ,it updates spinner sometime when start activity cursor becomes null , spinner list blank ,why?.it seems cursor null or count zero. though works fine of time there no chance of cursor being null or emplty.very strange behavior

public class mainactivity extends activity {     string[] data = { mediastore.video.media.data };     arraylist<string> path;     spinner path_spinner;     protected void oncreate(bundle savedinstancestate) {     // todo auto-generated method stub     super.oncreate(savedinstancestate);     setcontentview(r.layout.mainactivity);     path= new arraylist<string>();     path_spinner = (spinner) findviewbyid(r.id.folder_spinner);     cursor cursor = managedquery(mediastore.images.media.external_content_uri,data, null, null, null);     if(cursor != null && cursor.getcount() > 0)      {         cursor.movetofirst();         {             path.add(cursor.getstring(cursor.getcolumnindexorthrow(mediastore.images.media.data))             } while (cursor.movetonext());     }     arrayadapter<string> path_adapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1, path);     path_spinner.setadapter(path_adapter);     }     } 

update

if uri accessd @ time gives contentvalues values = new contentvalues(4);

values.put(mediastore.audio.media.title,"audio" + audiofile.getname());  values.put(mediastore.audio.media.mime_type, "audio/3gpp"); values.put(mediastore.audio.media.data, audiofile.getabsolutepath());         contentresolver contentresolver = getcontentresolver(); uri base = mediastore.audio.media.external_content_uri; uri newuri = contentresolver.insert(base, values); 

07-24 15:52:22.300: e/androidruntime(2583): caused by: java.lang.unsupportedoperationexception: unknown uri: content://media/external/audio/media

it working fine before cursor problem .it seems content provider not accesible @ moment. why?


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -