本文整理匯總了Java中android.database.Cursor.isLast方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.isLast方法的具體用法?Java Cursor.isLast怎麽用?Java Cursor.isLast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.Cursor
的用法示例。
在下文中一共展示了Cursor.isLast方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public BThread loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例2: buildAlbumInfo
import android.database.Cursor; //導入方法依賴的package包/類
private void buildAlbumInfo(ContentResolver cr) {
String[] distinctBucketColumns = new String[]{Media.BUCKET_ID, Media.BUCKET_DISPLAY_NAME};
Cursor bucketCursor = null;
try {
bucketCursor = cr.query(Media.EXTERNAL_CONTENT_URI, distinctBucketColumns, "0==0)" + " GROUP BY(" + Media.BUCKET_ID, null,
Media.DATE_MODIFIED + " desc");
if (bucketCursor != null && bucketCursor.moveToFirst()) {
do {
String buckId = bucketCursor.getString(bucketCursor.getColumnIndex(Media.BUCKET_ID));
String name = bucketCursor.getString(bucketCursor.getColumnIndex(Media.BUCKET_DISPLAY_NAME));
AlbumEntity album = buildAlbumInfo(name, buckId);
if (!TextUtils.isEmpty(buckId)) {
buildAlbumCover(cr, buckId, album);
}
} while (bucketCursor.moveToNext() && !bucketCursor.isLast());
}
} finally {
if (bucketCursor != null) {
bucketCursor.close();
}
}
}
示例3: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public UserThreadLink loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例4: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public UsedProduct loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例5: refresh
import android.database.Cursor; //導入方法依賴的package包/類
/** Resets all locally changed properties of the entity by reloading the values from the database. */
public void refresh(T entity) {
assertSinglePk();
K key = getKeyVerified(entity);
String sql = statements.getSelectByKey();
String[] keyArray = new String[]{key.toString()};
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
throw new DaoException("Entity does not exist in the database anymore: " + entity.getClass()
+ " with key " + key);
} else if (!cursor.isLast()) {
throw new DaoException("Expected unique result, but count was " + cursor.getCount());
}
readEntity(cursor, entity, 0);
attachEntity(key, entity, true);
} finally {
cursor.close();
}
}
示例6: count
import android.database.Cursor; //導入方法依賴的package包/類
/** Returns the count (number of results matching the query). Uses SELECT COUNT (*) sematics. */
public long count() {
checkThread();
Cursor cursor = dao.getDatabase().rawQuery(sql, parameters);
try {
if (!cursor.moveToNext()) {
throw new DaoException("No result for count");
} else if (!cursor.isLast()) {
throw new DaoException("Unexpected row count: " + cursor.getCount());
} else if (cursor.getColumnCount() != 1) {
throw new DaoException("Unexpected column count: " + cursor.getColumnCount());
}
return cursor.getLong(0);
} finally {
cursor.close();
}
}
示例7: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public TreeEntity loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例8: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public RelationEntity loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例9: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public BMessage loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例10: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public BLinkedAccount loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例11: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public ContactLink loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例12: loadDeep
import android.database.Cursor; //導入方法依賴的package包/類
public FollowerLink loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
示例13: addItem
import android.database.Cursor; //導入方法依賴的package包/類
private void addItem(final int allCount, final List<ImageMedia> result, Cursor cursor, @NonNull final IMediaTaskCallback<ImageMedia> callback) {
if (cursor != null && cursor.moveToFirst()) {
do {
String picPath = cursor.getString(cursor.getColumnIndex(Images.Media.DATA));
if (callback.needFilter(picPath)) {
BoxingLog.d("path:" + picPath + " has been filter");
} else {
String id = cursor.getString(cursor.getColumnIndex(Images.Media._ID));
String size = cursor.getString(cursor.getColumnIndex(Images.Media.SIZE));
String mimeType = cursor.getString(cursor.getColumnIndex(Images.Media.MIME_TYPE));
int width = 0;
int height = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
width = cursor.getInt(cursor.getColumnIndex(Images.Media.WIDTH));
height = cursor.getInt(cursor.getColumnIndex(Images.Media.HEIGHT));
}
ImageMedia imageItem = new ImageMedia.Builder(id, picPath).setThumbnailPath(mThumbnailMap.get(id))
.setSize(size).setMimeType(mimeType).setHeight(height).setWidth(width).build();
if (!result.contains(imageItem)) {
result.add(imageItem);
}
}
} while (!cursor.isLast() && cursor.moveToNext());
postMedias(result, allCount, callback);
} else {
postMedias(result, 0, callback);
}
clear();
}
示例14: loadVideos
import android.database.Cursor; //導入方法依賴的package包/類
private void loadVideos(ContentResolver cr, int page, @NonNull final IMediaTaskCallback<VideoMedia> callback) {
final List<VideoMedia> videoMedias = new ArrayList<>();
final Cursor cursor = cr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, MEDIA_COL, null, null,
MediaStore.Images.Media.DATE_MODIFIED + " desc" + " LIMIT " + page * IMediaTask.PAGE_LIMIT + " , " + IMediaTask.PAGE_LIMIT);
try {
int count = 0;
if (cursor != null && cursor.moveToFirst()) {
count = cursor.getCount();
do {
String data = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));
String id = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media._ID));
String title = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.TITLE));
String type = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.MIME_TYPE));
String size = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.SIZE));
String date = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATE_TAKEN));
String duration = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DURATION));
VideoMedia video = new VideoMedia.Builder(id, data).setTitle(title).setDuration(duration)
.setSize(size).setDataTaken(date).setMimeType(type).build();
videoMedias.add(video);
} while (!cursor.isLast() && cursor.moveToNext());
postMedias(callback, videoMedias, count);
} else {
postMedias(callback, videoMedias, 0);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}
示例15: onActivityResult
import android.database.Cursor; //導入方法依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// check whether the result is ok
if (resultCode == RESULT_OK) {
// Check for the request code, we might be usign multiple startActivityForReslut
switch (requestCode) {
case RESULT_PICK_CONTACT:
Uri uri = data.getData();
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
String number = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
number = number.replace("-", "");
number = number.replace(" ", "");
while(number.length() != 6 && !cursor.isLast()){
cursor.moveToNext();
number = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
number = number.replace("-", "");
number = number.replace(" ", "");
}
if (number.length() != 6){
Toast.makeText(this, "No valid RTVOICE number was found for selected contact", Toast.LENGTH_LONG).show();
break;
}
final EditText numberTextView = (EditText) findViewById(R.id.editText);
numberTextView.setText(number);
break;
}
} else {
Log.e("MainActivity", "Failed to pick contact");
}
}