如何在ContentProvider中传递Rawquery?

时间:2012-08-01 10:09:23

标签: java android android-contentprovider

如何将rawQuery使用ContentProvider从一个应用程序传递到另一个应用程序?示例:select max(date) from tblename

示例:查询主要活动:

private Uri CONTENT_URI = Uri.parse("content://ubra.c.apps.pro/Details");
cursor = getContentResolver().query(CONTENT_URI, null,null, null, "datePDate DESC");

ContentProvider

static UriMatcher uriMatcher;
static String PRO_NAME = "ubra.c.apps.pro";
Uri CONTENT_URI = Uri.parse("content://" + PRO_NAME
        + "/Details");

public Cursor query(Uri uri, String[] arg1, String arg2, String[] arg3,
        String arg4) {
    switch (uriMatcher.match(uri)) 
    {
    case 1:         
        CPcursor = DBConnection.query("Details",  arg1, arg2, arg3,arg2, arg2, arg4);
        break;

如何在这里使用rawQuery

1 个答案:

答案 0 :(得分:1)

问题的最佳解决方案。

public Cursor query(Uri uri, String[] arg1, String arg2, String[] arg3,String arg4) 
{
    switch (uriMatcher.match(uri)) 
    {
    case 1:         
       CPcursor =  DBConnection.rawQuery("Enter your SQL query Here"')", null);
        break;
}
}