java - Get list of all names in content provider -
i'm using "calls.content_uri" content provider. retrived column names, let's say, names column name "name" in content provider.
i have code below:
uri = calls.content_uri; string[] projection = {"name"}; string selection = null; string[] selectionargs = null; string sort = null; resolver = getcontentresolver(); cursor = resolver.query(uri, projection, selection, selectionargs, sort); log.i("tutorial", "counts :"+cursor.getcount()); string s; cursor.movetofirst(); for(int x=0; x<cursor.getcount(); x++){ s = cursor.getstring(x); log.i("tutorial", ""+s); //cursor.movetonext(); }
but retrives 1 name. have list of names saved in phone like:
john peter mark suzy . . x
but got 1 name like:
peter. hope i've been clear enough.
what's problem? in advance.
i think you
arraylist<string> namelist = new arraylist<string>(); string[] projection = {"name"}; string selection = null; string[] selectionargs = null; string sort = null; resolver = getcontentresolver(); cursor = resolver.query(uri, projection, selection, selectionargs, sort); log.i("tutorial", "counts :"+cursor.getcount()); string s; if(cursor.movetofirst()) { { namelist.add(cursor.getstring(0)); //your code //s = cursor.getstring(x); log.i("tutorial", ""+cursor.getstring(0)); }while(cursor.movetonext()); }
Comments
Post a Comment