本文整理汇总了Java中android.database.Cursor.close方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.close方法的具体用法?Java Cursor.close怎么用?Java Cursor.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.Cursor
的用法示例。
在下文中一共展示了Cursor.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _queryPathFromMediaStore
import android.database.Cursor; //导入方法依赖的package包/类
private static String _queryPathFromMediaStore(Context context, Uri uri, String selection, String[] selectionArgs) {
String filePath = null;
try {
String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null) {
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
filePath = cursor.getString(column_index);
cursor.close();
}
} catch (IllegalArgumentException e) {
//LogUtils.error(e);
}
return filePath;
}
示例2: checkForDuplicateImage
import android.database.Cursor; //导入方法依赖的package包/类
/**
* Used to find out if we are in a situation where the Camera Intent adds to images
* to the content store. If we are using a FILE_URI and the number of images in the DB
* increases by 2 we have a duplicate, when using a DATA_URL the number is 1.
*
* @param type FILE_URI or DATA_URL
*/
private void checkForDuplicateImage(int type) {
int diff = 1;
Uri contentStore = whichContentStore();
Cursor cursor = queryImgDB(contentStore);
int currentNumOfImages = cursor.getCount();
if (type == FILE_URI && this.saveToPhotoAlbum) {
diff = 2;
}
// delete the duplicate file if the difference is 2 for file URI or 1 for Data URL
if ((currentNumOfImages - numPics) == diff) {
cursor.moveToLast();
int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)));
if (diff == 2) {
id--;
}
Uri uri = Uri.parse(contentStore + "/" + id);
this.cordova.getActivity().getContentResolver().delete(uri, null, null);
cursor.close();
}
}
示例3: getDownloadVideoData
import android.database.Cursor; //导入方法依赖的package包/类
public static DownloadVideo getDownloadVideoData(String vid) {
Cursor cursor = null;
DownloadVideo downloadVideo = null;
try {
Query query = new Query(sConext.getContentResolver());
query.setUri(DOWNLOAD_VIDEO_URI);
query.setSelection("vid = " + vid);
cursor = query(query);
cursor.moveToFirst();
downloadVideo = DownloadVideoTable.cursorToDownloadVideo(cursor);
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
} catch (Exception e) {
e.printStackTrace();
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
} catch (Throwable th) {
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
}
return downloadVideo;
}
示例4: getDownloadVideoByVid
import android.database.Cursor; //导入方法依赖的package包/类
public DownloadVideo getDownloadVideoByVid(long vid) {
Cursor cursor = null;
try {
cursor = queryByID(DownloadVideoTable.CONTENT_URI, null, "vid = " + vid, null, null);
if (cursor != null) {
cursor.moveToFirst();
DownloadVideo cursorToDownloadVideo = DownloadVideoTable.cursorToDownloadVideo(cursor);
return cursorToDownloadVideo;
}
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
return null;
} finally {
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
}
}
示例5: getBuildID
import android.database.Cursor; //导入方法依赖的package包/类
/**
* Returns a build's ID given its unique name. Returns -1
* if no build with the given name exists in DB.
*
* @param uniqueName
* @return Build table row ID
*/
public long getBuildID(String uniqueName) {
Cursor cursor = null;
try {
cursor = mDb.query(TABLE_BUILD_ORDER,
new String[]{KEY_BUILD_ORDER_ID},
KEY_NAME + " = ?",
new String[]{uniqueName}, null, null, null);
if (cursor.getCount() == 0)
return -1;
cursor.moveToFirst();
return cursor.getLong(0);
} finally {
if (cursor != null)
cursor.close();
}
}
示例6: get
import android.database.Cursor; //导入方法依赖的package包/类
private static VersionedRook get(Context context, Uri uri) {
Cursor cursor = context.getContentResolver().query(
ProviderContract.LocalDbRepo.ContentUri.dbRepos(),
null,
ProviderContract.LocalDbRepo.Param.URL + " = ?",
new String[] { uri.toString() },
null);
try {
if (cursor.moveToFirst()) {
return fromCursor(cursor);
}
} finally {
cursor.close();
}
return null;
}
示例7: getListAno
import android.database.Cursor; //导入方法依赖的package包/类
public List<String> getListAno() {
List<String> mList = new ArrayList<>();
Cursor cursor;
cursor = Funcoes.mDataBase.query(mTable, new String[]{"ano"}, null, null, "ano", null, null);
while (cursor.moveToNext()) {
mList.add(cursor.getString(cursor.getColumnIndex("ano")));
}
cursor.close();
return mList;
}
示例8: getIdeasCount
import android.database.Cursor; //导入方法依赖的package包/类
/**
* Count the ideas in the different tabs for the current project (table)
*
* @param tabNumber 0 for NOW+LATER, 1 for Now/IDEAS, 2 for LATER, 3 for DONE
* @return
*/
public int getIdeasCount(int tabNumber) {
int count = 0;
Cursor cursor = null;
try {
switch (tabNumber) {
case 0: //NOW+LATER
cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=0 and temp=0", null);
break;
case 1: //NOW/IDEAS
cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=0 and temp=0 and later=0", null);
break;
case 2: //LATER
cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=0 and temp=0 and later=1", null);
break;
case 3: //DONE
cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=1 and temp=0", null);
break;
}
cursor.moveToFirst();
count = cursor.getInt(0);
} finally {
if (cursor != null) {
cursor.close();
}
}
return count;
}
示例9: getAllGroupMessage
import android.database.Cursor; //导入方法依赖的package包/类
/**
* 获取所有的群结构表
*
* @return 结果集
*/
public List<GroupTableMessage> getAllGroupMessage() {
List<GroupTableMessage> list = null;
if (mDatabase.isOpen()) {
Cursor cursor = mDatabase.rawQuery("select * from " + GROUP_TABLE, null);
if (cursor != null) {
list = new ArrayList<>();
GroupTableMessage groupTableMessage;
while (cursor.moveToNext()) {
groupTableMessage = new GroupTableMessage();
groupTableMessage.setGroupId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_ID)));
groupTableMessage.setObjectId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_OBJECT_ID)));
groupTableMessage.setCreatorId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_CREATOR_ID)));
groupTableMessage.setCreatedTime(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_CREATE_TIME)));
groupTableMessage.setGroupDescription(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_DESCRIPTION)));
groupTableMessage.setGroupAvatar(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_AVATAR)));
groupTableMessage.setGroupName(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NAME)));
groupTableMessage.setGroupNick(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NICK)));
groupTableMessage.setToId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_TO_ID)));
groupTableMessage.setSendStatus(cursor.getInt(cursor.getColumnIndexOrThrow(GROUP_SEND_STATUS)));
groupTableMessage.setReadStatus(cursor.getInt(cursor.getColumnIndexOrThrow(GROUP_READ_STATUS)));
groupTableMessage.setGroupNumber(CommonUtils.string2list(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NUMBER))));
groupTableMessage.setNotification(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NOTIFICATION)));
list.add(groupTableMessage);
}
if (!cursor.isClosed()) {
cursor.close();
}
}
}
return list;
}
示例10: onLoadFinished
import android.database.Cursor; //导入方法依赖的package包/类
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
switch (loader.getId()) {
case TAG_METADATA_TOKEN:
mTagMetadata = new TagMetadata(cursor);
onTagMetadataLoaded();
break;
default:
cursor.close();
}
}
示例11: checkForFreshData
import android.database.Cursor; //导入方法依赖的package包/类
@Override
public void checkForFreshData() {
// every first one of the 3 lists is with header
// add them in advance
types.add(TYPE_ZHIHU_WITH_HEADER);
Cursor cursor = db.rawQuery("select * from Zhihu where bookmark = ?", new String[]{"1"});
if (cursor.moveToFirst()) {
do {
ZhihuDailyNews.Question question = gson.fromJson(cursor.getString(cursor.getColumnIndex("zhihu_news")), ZhihuDailyNews.Question.class);
zhihuList.add(question);
types.add(TYPE_ZHIHU_NORMAL);
} while (cursor.moveToNext());
}
types.add(TYPE_GUOKR_WITH_HEADER);
cursor = db.rawQuery("select * from Guokr where bookmark = ?", new String[]{"1"});
if (cursor.moveToFirst()) {
do {
GuokrHandpickNews.result result = gson.fromJson(cursor.getString(cursor.getColumnIndex("guokr_news")), GuokrHandpickNews.result.class);
guokrList.add(result);
types.add(TYPE_GUOKR_NORMAL);
} while (cursor.moveToNext());
}
types.add(TYPE_DOUBAN_WITH_HEADER);
cursor = db.rawQuery("select * from Douban where bookmark = ?", new String[]{"1"});
if (cursor.moveToFirst()) {
do {
DoubanMomentNews.posts post = gson.fromJson(cursor.getString(cursor.getColumnIndex("douban_news")), DoubanMomentNews.posts.class);
doubanList.add(post);
types.add(TYPE_DOUBAN_NORMAL);
} while (cursor.moveToNext());
}
cursor.close();
}
示例12: getNotices
import android.database.Cursor; //导入方法依赖的package包/类
public ArrayList<Notice> getNotices() {
ArrayList<Notice> alarms = new ArrayList();
Cursor cursor = this.db.query(TABLE_NAME, null, null, null, null, null, "created_at DESC");
if (cursor != null) {
while (cursor.moveToNext()) {
alarms.add(selectWithCursor(cursor));
}
cursor.close();
}
return alarms;
}
示例13: getRegionTreeList
import android.database.Cursor; //导入方法依赖的package包/类
public static List<Tree> getRegionTreeList(Context context, Projection projectionRigion) {
if (dbstatic == null) {
TreeDBHelper dbHelper = new TreeDBHelper(context);
dbstatic = dbHelper.getReadableDatabase();
}
String[] projection = new String[]{TreeDBContract.TreeEntry.COLUMN_NAME_TRAE_ART,
TreeDBContract.TreeEntry.COLUMN_NAME_DANSK_NAVN,
COLUMN_NAME_COORDINATE_LAT,
TreeDBContract.TreeEntry.COLUMN_NAME_COORDINATE_LON};
LatLngBounds bounds = projectionRigion.getVisibleRegion().latLngBounds;
String selection = COLUMN_NAME_COORDINATE_LAT +
" Between " + bounds.southwest.latitude +
" And " + bounds.northeast.latitude +
" And " + COLUMN_NAME_COORDINATE_LON +
" Between " + bounds.southwest.longitude +
" And " + bounds.northeast.longitude +
" LIMIT 2000";
Cursor cursor = dbstatic.query(TreeDBContract.TreeEntry.TABLE_NAME, projection, selection, null, null, null, null);
List<Tree> trees = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
Tree tree = new Tree(cursor.getString(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_TRAE_ART)),
cursor.getString(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_DANSK_NAVN)),
cursor.getDouble(cursor.getColumnIndex(COLUMN_NAME_COORDINATE_LAT)),
cursor.getDouble(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_COORDINATE_LON)));
trees.add(tree);
}
cursor.close();
return trees;
}
示例14: getUserById
import android.database.Cursor; //导入方法依赖的package包/类
public User getUserById(long Id){
SQLiteDatabase db = dbHandler.getReadableDatabase();
String selectQuery = "SELECT " +
User.KEY_ID + "," +
User.KEY_LAST_NAME + "," +
User.KEY_FIRST_NAME + "," +
User.KEY_EMAIL + "," +
User.KEY_COUNTRY +
" FROM " + User.TABLE
+ " WHERE " +
User.KEY_ID + "=?";// It's a good practice to use parameter ?, instead of concatenate string
User user = new User();
Cursor cursor = db.rawQuery(selectQuery, new String[] { String.valueOf(Id) } );
if (cursor.moveToFirst()) {
do {
user.id =cursor.getInt(cursor.getColumnIndex(User.KEY_ID));
user.last_name =cursor.getString(cursor.getColumnIndex(User.KEY_LAST_NAME));
user.first_name =cursor.getString(cursor.getColumnIndex(User.KEY_FIRST_NAME));
user.email =cursor.getString(cursor.getColumnIndex(User.KEY_EMAIL));
user.home_country = cursor.getInt(cursor.getColumnIndex(User.KEY_COUNTRY));
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return user;
}
示例15: getContact
import android.database.Cursor; //导入方法依赖的package包/类
public User getContact(String uid) {
User user = null;
if (mDatabase.isOpen()) {
Cursor cursor = mDatabase.query(CONTACTS_TABLE_NAME, null, CONTACTS_UID + " =?", new String[]{uid}, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
user = new User();
user.setUsername(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_NAME)));
user.setObjectId(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_UID)));
user.setAvatar(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_AVATAR)));
user.setSex(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_SEX)).equals("男"));
user.setNick(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_NICK)));
user.setSortedKey(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_SORT_KEY)));
user.setInstallId(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_INSTALLATION_ID)));
user.setSignature(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_SIGNATURE)));
user.setMobilePhoneNumber(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_PHONE)));
user.setEmail(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_EMAIL)));
user.setBirthDay(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_BIRTHDAY)));
String location = cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_LOCATION));
if (location != null && !location.equals("")) {
String[] loglat = location.split("&");
user.setLocation(new BmobGeoPoint(Double.parseDouble(loglat[0]), Double.parseDouble(loglat[1])));
}
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
return user;
}