当前位置: 首页>>代码示例>>Java>>正文


Java ContentProvider.query方法代码示例

本文整理汇总了Java中android.content.ContentProvider.query方法的典型用法代码示例。如果您正苦于以下问题:Java ContentProvider.query方法的具体用法?Java ContentProvider.query怎么用?Java ContentProvider.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ContentProvider的用法示例。


在下文中一共展示了ContentProvider.query方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: query

import android.content.ContentProvider; //导入方法依赖的package包/类
@Implementation
public final Cursor query(Uri uri, String[] projection, String selection,
    String[] selectionArgs, String sortOrder) {
  ContentProvider provider = getProvider(uri);
  if (provider != null) {
    return provider.query(uri, projection, selection, selectionArgs, sortOrder);
  } else {
    TestCursor returnCursor = getCursor(uri);
    if (returnCursor == null) {
      return null;
    }

    returnCursor.setQuery(uri, projection, selection, selectionArgs,
        sortOrder);
    return returnCursor;
  }
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:18,代码来源:ShadowContentResolver.java

示例2: query

import android.content.ContentProvider; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    ContentProvider provider = getContentProvider(uri);
    Uri pluginUri = Uri.parse(uri.getQueryParameter(KEY_URI));
    if (provider != null) {
        return provider.query(pluginUri, projection, selection, selectionArgs, sortOrder);
    }

    return null;
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:11,代码来源:RemoteContentProvider.java

示例3: query

import android.content.ContentProvider; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    PluginProviderHelper.PluginUri pu = mHelper.toPluginUri(uri);
    if (pu == null) {
        return null;
    }
    ContentProvider cp = mHelper.getProvider(pu);
    if (cp == null) {
        return null;
    }
    return cp.query(pu.transferredUri, projection, selection, selectionArgs, sortOrder);
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:13,代码来源:PluginPitProviderBase.java

示例4: query

import android.content.ContentProvider; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection,
                    String selection, String[] selectionArgs, String sortOrder) {
    ContentProvider mContentProvider = getContentProvider();
    if (mContentProvider != null) {
        return mContentProvider.query(uri, projection, selection, selectionArgs, sortOrder);
    }
    return null;
}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:10,代码来源:ProviderProxy.java

示例5: testQuery

import android.content.ContentProvider; //导入方法依赖的package包/类
public void testQuery() {
    ContentProvider provider = getProvider();
    for (Uri uri : validUris) {
        Cursor cursor = provider.query(uri, null, null, null, null);
        assertNotNull(cursor);
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:8,代码来源:SmsLogProviderTest.java

示例6: testInsertAndRead

import android.content.ContentProvider; //导入方法依赖的package包/类
public void testInsertAndRead() {
    ContentProvider provider = getProvider();
    // Data
    SmsLog vo = new SmsLog()//
            .setPhone("0601020304") //
            .setAction(SmsMessageActionEnum.GEOPING_REQUEST)//
            .setTime(java.lang.System.currentTimeMillis()) //
            .setMessage("th7lhawmo,z31,y1e14h,xt3jbc,aa,s0,pg,b1p") //
            .setSmsLogType(SmsLogTypeEnum.SEND_ACK);
    ContentValues values =  SmsLogHelper.getContentValues(vo);
    // Insert
    Uri uri = provider.insert(CONTENT_URI, values);
    // Select
    Cursor cursor = provider.query(uri, null, null, null, null);
    try {
        assertEquals(1, cursor.getCount());
        cursor.moveToFirst();
        SmsLogHelper helper = new SmsLogHelper().initWrapper(cursor);
        SmsLog voDb = helper.getEntity(cursor);
        assertEquals(Long.valueOf(uri.getLastPathSegment()).longValue(), voDb.id);
        assertEquals(vo.phone, voDb.phone);
        assertEquals(vo.action, voDb.action);
        assertEquals(vo.time, voDb.time);
        assertEquals(vo.message, voDb.message);
        assertEquals(vo.smsLogType, voDb.smsLogType);
    } finally {
        cursor.close();
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:30,代码来源:SmsLogProviderTest.java

示例7: testInsertAndRead

import android.content.ContentProvider; //导入方法依赖的package包/类
public void testInsertAndRead() {
    ContentProvider provider = getProvider();
    // Data
    Pairing vo = new Pairing()//
            .setPhone("0601020304") //
            .setShowNotification(true)//
            .setPairingTime(System.currentTimeMillis())
            .setAuthorizeType(PairingAuthorizeTypeEnum.AUTHORIZE_ALWAYS);
    ContentValues values = PairingHelper.getContentValues(vo);
    // Insert
    Uri uri = provider.insert(CONTENT_URI, values);
    // Select
    Cursor cursor = provider.query(uri, null, null, null, null);
    try {
        assertEquals(1, cursor.getCount());
        cursor.moveToFirst();
        PairingHelper helper = new PairingHelper().initWrapper(cursor);
        Pairing voDb = helper.getEntity(cursor);
        assertEquals(Long.valueOf(uri.getLastPathSegment()).longValue(), voDb.id);
        assertEquals(vo.phone, voDb.phone);
        assertEquals(vo.showNotification, voDb.showNotification);
        assertEquals(vo.authorizeType, voDb.authorizeType);
        assertEquals(vo.pairingTime, voDb.pairingTime);
    } finally {
        cursor.close();
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:28,代码来源:PairingProviderTest.java

示例8: testInsertAndSearchForPhone

import android.content.ContentProvider; //导入方法依赖的package包/类
public void testInsertAndSearchForPhone() {
    ContentProvider provider = getProvider();
    // Data
    Pairing vo = new Pairing()//
            .setPhone("0601020304") //
            .setShowNotification(true)//
            .setPairingTime(System.currentTimeMillis())
            .setAuthorizeType(PairingAuthorizeTypeEnum.AUTHORIZE_ALWAYS);
    ContentValues values = PairingHelper.getContentValues(vo);
    // Insert
    Uri uri = provider.insert(CONTENT_URI, values);
    // Select
    Uri searchPhoneUri01 = Uri.withAppendedPath(PairingProvider.Constants.CONTENT_URI_PHONE_FILTER, Uri.encode("+33601020304"));
    Uri searchPhoneUri02 = Uri.withAppendedPath(PairingProvider.Constants.CONTENT_URI_PHONE_FILTER, Uri.encode("0601020304"));
    for (Uri searchPhoneUri : new Uri[] { searchPhoneUri01, searchPhoneUri02 }) {
        Cursor cursor = provider.query(searchPhoneUri, null, null, null, null);
        try {
            assertEquals(1, cursor.getCount());
            cursor.moveToFirst();
            PairingHelper helper = new PairingHelper().initWrapper(cursor);
            Pairing voDb = helper.getEntity(cursor);
            assertEquals(Long.valueOf(uri.getLastPathSegment()).longValue(), voDb.id);
            assertEquals(vo.phone, voDb.phone);
            assertEquals(vo.showNotification, voDb.showNotification);
            assertEquals(vo.pairingTime, voDb.pairingTime);
            assertEquals(vo.authorizeType, voDb.authorizeType);
        } finally {
            cursor.close();
        }
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:32,代码来源:PairingProviderTest.java

示例9: testInsertAndRead

import android.content.ContentProvider; //导入方法依赖的package包/类
public void testInsertAndRead() {
    ContentProvider provider = getProvider();
    // Data
    for (GeoTrack vo : new GeoTrack[] { getGeoTrack01(PROVIDER_GPS), getGeoTrack01(PROVIDER_NETWORK)}) {
        GeoTrackHelper helper = new GeoTrackHelper();
        ContentValues values = helper.getContentValues(vo);
        // Insert
        Uri uri = provider.insert(CONTENT_URI, values);
        // Select
        Cursor cursor = provider.query(uri, null, null, null, null);
        try {
            assertEquals(1, cursor.getCount());
            cursor.moveToFirst();
            helper.initWrapper(cursor);
            GeoTrack voDb = helper.getEntity(cursor);
            assertEquals(Long.valueOf(uri.getLastPathSegment()).longValue(), voDb.id);
            assertEquals(vo.phone, voDb.phone);
            assertEquals(vo.getTime(), voDb.getTime());
            assertEquals(vo.getLatitudeE6(), voDb.getLatitudeE6());
            assertEquals(vo.getLongitude(), voDb.getLongitude());
            assertEquals(vo.getAccuracy(), voDb.getAccuracy());
            assertEquals(vo.getAltitude(), voDb.getAltitude());
            assertEquals(vo.getSpeed(), voDb.getSpeed());
            assertEquals(vo.getBearing(), voDb.getBearing());
            assertEquals(vo.address, voDb.address);
        } finally {
            cursor.close();
        }
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:31,代码来源:GeoTrackProviderTest.java

示例10: testInsertAndRead

import android.content.ContentProvider; //导入方法依赖的package包/类
public void testInsertAndRead() {
    ContentProvider provider = getProvider();
    // Data
    Person vo = new Person()//
            .setPhone("0601020304") //
            .setColor(Color.GREEN)//
            .setPairingTime(System.currentTimeMillis())
            .setDisplayName("Lena Sj��blom");
    ContentValues values = PersonHelper.getContentValues(vo);
    // Insert
    Uri uri = provider.insert(CONTENT_URI, values);
    // Select
    Cursor cursor = provider.query(uri, null, null, null, null);
    try {
        assertEquals(1, cursor.getCount());
        cursor.moveToFirst();
        PersonHelper helper = new PersonHelper().initWrapper(cursor);
        Person voDb = helper.getEntity(cursor);
        assertEquals(Long.valueOf(uri.getLastPathSegment()).longValue(), voDb.id);
        assertEquals(vo.phone, voDb.phone);
        assertEquals(vo.color, voDb.color);
        assertEquals(vo.displayName, voDb.displayName);
        assertEquals(vo.pairingTime, voDb.pairingTime);
    } finally {
        cursor.close();
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:28,代码来源:PersonProviderTest.java

示例11: testInsertAndSearchForPhone

import android.content.ContentProvider; //导入方法依赖的package包/类
public void testInsertAndSearchForPhone() {
    ContentProvider provider = getProvider();
    // Data
    Person vo = new Person()//
    .setPhone("0601020304") //
    .setColor(Color.GREEN)//
    .setPairingTime(System.currentTimeMillis())
    .setDisplayName("Lena Sj��blom");
    ContentValues values = PersonHelper.getContentValues(vo);
    // Insert
    Uri uri = provider.insert(CONTENT_URI, values);
    // Select
    Uri searchPhoneUri01 = Uri.withAppendedPath(PersonProvider.Constants.CONTENT_URI_PHONE_FILTER, Uri.encode("+33601020304"));
    Uri searchPhoneUri02 = Uri.withAppendedPath(PersonProvider.Constants.CONTENT_URI_PHONE_FILTER, Uri.encode("0601020304"));
    for (Uri searchPhoneUri : new Uri[] { searchPhoneUri01, searchPhoneUri02 }) {
        Cursor cursor = provider.query(searchPhoneUri, null, null, null, null);
        try {
            assertEquals(1, cursor.getCount());
            cursor.moveToFirst();
            PersonHelper helper = new PersonHelper().initWrapper(cursor);
            Person voDb = helper.getEntity(cursor);
            assertEquals(Long.valueOf(uri.getLastPathSegment()).longValue(), voDb.id);
            assertEquals(vo.phone, voDb.phone);
            assertEquals(vo.color, voDb.color);
            assertEquals(vo.pairingTime, voDb.pairingTime);
            assertEquals(vo.displayName, voDb.displayName);
        } finally {
            cursor.close();
        }
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:32,代码来源:PersonProviderTest.java


注:本文中的android.content.ContentProvider.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。