Passing query variables to the ContentProvider in Android -
i'm wanting know correct way of passing parameters database query using contentprovider pattern is.
is follow - i.e. & args in update method.
getcontentresolver().update(uri, cv,where, args);
or appending values @ end of uri - in example in docs - see case 2?
public class exampleprovider extends contentprovider { ...... ...... // implements contentprovider.query() public cursor query( uri uri, string[] projection,string selection, string[] selectionargs, string sortorder) { switch (surimatcher.match(uri)) { case 1: if (textutils.isempty(sortorder)) sortorder = "_id asc"; break; case 2: selection = selection + "_id = " uri.getlastpathsegment(); break;
and of these approaches best. i've seen both used, unsure of respective merits.
Comments
Post a Comment