本文整理汇总了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;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
}