我是内容提供商的新手,我一直在参考this文档以了解和创建自定义内容提供者。内容提供商 - 多个参数
我对内容提供商的内容描述符类这样的路径:
public static final String PATH = "tbl_reco_index_contents";
public static final String PATH_FOR_ID = "tbl_reco_index_contents/*";
有了下面的代码,我能够获取从中我需要的列中的数据,没有任何问题:
public static final String AUTHORITY = "com.nyk.launcherprovider";
private static final Uri BASE_URI = Uri.parse("content://" + AUTHORITY);
public static final String PATH = "tbl_reco_index_contents";
public static final Uri CONTENT_URI = BASE_URI.buildUpon().appendPath(PATH).build();
cur = this.getContentResolver().query(CONTENT_URI, new String[]{
"reco_index_content_name",
"reco_index_content_url"
}, null, null, null);
cur.moveToFirst();
for(int i=0;i<cur.getCount();i++){
System.out.println("Name is:"+cur.getString(10));
System.out.println("URL is:"+cur.getString(11));
cur.moveToNext();
}
我不知道,我怎么可以在这里使用where条件来获取数据。即;如果我需要添加如WHERE user_profile_number = 2 and pkg_name = 'abc'
这样的条件,我该如何处理以上代码。
任何帮助,非常感谢。
您还可以使用选择的参数,如果你不知道什么会在where子句中的值的数据。 – anon