本文整理匯總了Java中android.database.Cursor.isClosed方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.isClosed方法的具體用法?Java Cursor.isClosed怎麽用?Java Cursor.isClosed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.Cursor
的用法示例。
在下文中一共展示了Cursor.isClosed方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isExist
import android.database.Cursor; //導入方法依賴的package包/類
/**
* 判斷數據表是否存在
*
* @param tableName tableName
* @return 判斷數據表是否存在
*/
public boolean isExist(String tableName) {
if (TextUtils.isEmpty(tableName)) {
return false;
}
boolean exits = false;
SQLiteDatabase db;
Cursor cursor = null;
String sql = "select * from sqlite_master where name=" + "'" + tableName + "'";
try {
db = getReadableDatabase();
cursor = db.rawQuery(sql, null);
if (cursor.getCount() != 0) {
exits = true;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
return exits;
}
示例2: deliverResult
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public void deliverResult(Cursor newCursor) {
if (isReset()) {
if (newCursor != null) {
newCursor.close();
}
return;
}
Cursor oldCursor = this.cursor;
this.cursor = newCursor;
if (isStarted()) {
super.deliverResult(newCursor);
}
if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) {
oldCursor.close();
}
}
示例3: getDownloadFinishVideo
import android.database.Cursor; //導入方法依賴的package包/類
public static DownloadVideo getDownloadFinishVideo(long vid) {
Cursor cursor = null;
DownloadVideo downloadVideo = null;
try {
Query query = new Query(sConext.getContentResolver());
query.setUri(DOWNLOAD_VIDEO_URI);
query.setSelection("vid = " + vid + " and " + "state" + " = " + 4);
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: 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;
}
示例5: onLoadOtherFile
import android.database.Cursor; //導入方法依賴的package包/類
private List<Folder> onLoadOtherFile(Cursor cursor) {
if (cursor.getPosition() != -1) {
cursor.moveToPosition(-1);
}
List<Folder> folders = new ArrayList<>();
List<BaseFile> files = new ArrayList<>();
while (!cursor.isClosed() && cursor.moveToNext()) {
String path = cursor.getString(cursor.getColumnIndexOrThrow(DATA));
if (path != null && contains(mSuffixArgs, path)) {
//Create a File instance
OtherFile file = new OtherFile();
file.setId(cursor.getLong(cursor.getColumnIndexOrThrow(_ID)));
file.setName(cursor.getString(cursor.getColumnIndexOrThrow(TITLE)));
file.setPath(cursor.getString(cursor.getColumnIndexOrThrow(DATA)));
file.setSize(cursor.getLong(cursor.getColumnIndexOrThrow(SIZE)));
file.setDate(cursor.getLong(cursor.getColumnIndexOrThrow(DATE_ADDED)));
file.setMimeType(cursor.getString(cursor.getColumnIndexOrThrow(MIME_TYPE)));
files.add(file);
//Create a Folder
Folder folder = new Folder();
folder.setName(Util.extractName(Util.extractDirectory(file.getPath())));
folder.setPath(Util.extractDirectory(file.getPath()));
if (!folders.contains(folder)) {
folder.addFile(file);
folders.add(folder);
} else {
folders.get(folders.indexOf(folder)).addFile(file);
}
}
}
Folder all = new Folder();
all.setName(mContext.getString(R.string.all));
all.setFiles(files);
all.setSelected(true);
folders.add(0, all);
return folders;
}
示例6: hasGroupTableMessage
import android.database.Cursor; //導入方法依賴的package包/類
private boolean hasGroupTableMessage(String id) {
boolean result = false;
if (mDatabase.isOpen()) {
Cursor cursor = mDatabase.query(GROUP_TABLE, null, GROUP_ID + " =?", new String[]{id}, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
result = true;
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
return result;
}
示例7: getAllPartInfoByVid
import android.database.Cursor; //導入方法依賴的package包/類
public ArrayList<PartInfoBean> getAllPartInfoByVid(long vid) {
Throwable th;
Cursor cursor = null;
String selection = "";
try {
cursor = queryByID(ThreadInfoTable.CONTENT_URI, null, "download_id = " + vid, null, null);
if (cursor == null || cursor.getCount() == 0) {
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
return null;
}
ArrayList<PartInfoBean> arrayList;
ArrayList<PartInfoBean> arrayPartInfo = new ArrayList();
while (cursor.moveToNext()) {
try {
arrayPartInfo.add(ThreadInfoTable.cursorToPartInfo(cursor));
} catch (Throwable th2) {
th = th2;
arrayList = arrayPartInfo;
}
}
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
arrayList = arrayPartInfo;
return arrayPartInfo;
} catch (Throwable th3) {
th = th3;
if (!(cursor == null || cursor.isClosed())) {
cursor.close();
}
throw th;
}
}
示例8: getHighScore
import android.database.Cursor; //導入方法依賴的package包/類
public String getHighScore() {
Cursor cursor = this.myDataBase.rawQuery("SELECT highscore FROM user_Table", null);
if (cursor.moveToFirst()) {
do {
return cursor.getString(0);
} while (cursor.moveToNext());
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
return "0";
}
示例9: onCreate
import android.database.Cursor; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.viewnotepad);
name = (EditText) findViewById(R.id.txtname);
name.setFocusable(true);
content = (EditText) findViewById(R.id.txtcontent);
coordinatorLayout = (RelativeLayout) findViewById(R.id.coordinatorLayout);
mydb = new NDb(this);
Bundle extras = getIntent().getExtras();
if (extras != null) {
int Value = extras.getInt("id");
if (Value > 0) {
snackbar = Snackbar
.make(coordinatorLayout, "Note Name : "+String.valueOf(Value), Snackbar.LENGTH_LONG);
snackbar.show();
Cursor rs = mydb.getData(Value);
id_To_Update = Value;
rs.moveToFirst();
String nam = rs.getString(rs.getColumnIndex(NDb.name));
String contents = rs.getString(rs.getColumnIndex(NDb.remark));
if (!rs.isClosed()) {
rs.close();
}
name.setText((CharSequence) nam);
content.setText((CharSequence) contents);
}
}
}
示例10: hasHappyInfo
import android.database.Cursor; //導入方法依賴的package包/類
private boolean hasHappyInfo(String key) {
boolean result = false;
if (mDatabase.isOpen()) {
Cursor cursor = mDatabase.query(HAPPY_TABLE, null, HAPPY_KEY + " =?", new String[]{key}, null, null, null);
if (cursor.moveToFirst()) {
result = true;
}
if (!cursor.isClosed()) {
cursor.close();
}
}
return result;
}
示例11: isRecentMsgExist
import android.database.Cursor; //導入方法依賴的package包/類
/**
* 判斷最近消息列表中是否有該用戶的消息
*
* @param uid 用戶ID
* @return 結果
*/
private boolean isRecentMsgExist(String uid) {
boolean result = false;
if (mDatabase.isOpen()) {
Cursor cursor = mDatabase.query(RECENT_TABLE_NAME, null, RECENT_TO_ID + " =?", new String[]{uid}, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
result = true;
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
return result;
}
示例12: getContactsWithoutBlack
import android.database.Cursor; //導入方法依賴的package包/類
public List<User> getContactsWithoutBlack() {
List<User> list = new ArrayList<>();
if (mDatabase.isOpen()) {
Cursor cursor = mDatabase.query(CONTACTS_TABLE_NAME, null, CONTACTS_IS_BLACK + " =?", new String[]{Constant.BLACK_NO}, null, null, null);
if (cursor != null) {
User user;
while (cursor.moveToNext()) {
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)));
user.setAddress(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_ADDRESS)));
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])));
}
list.add(user);
}
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
return list;
}
示例13: onLoadFinished
import android.database.Cursor; //導入方法依賴的package包/類
@Override
public void onLoadFinished(Loader<Cursor> loader, final Cursor data) {
if (data.isClosed()) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
handleCursor(data);
}
}).start();
}
示例14: getFileInfo
import android.database.Cursor; //導入方法依賴的package包/類
public FileInfo getFileInfo(String uploadFileName){
FileInfo fileInfo = new FileInfo();
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
if (db != null && db.isOpen()) {
Cursor cur = db.rawQuery("select upload_file_name, isForceUpload, isResend from file_info where upload_file_name = ?",
new String[]{uploadFileName});
if (!cur.isClosed()) {
try{
while(cur.moveToNext()){
if (cur.getInt(1) == 0) {
fileInfo.isForceUpload = false;
} else {
fileInfo.isForceUpload = true;
}
if (cur.getInt(2) == 0) {
fileInfo.isResend = false;
} else {
fileInfo.isResend = true;
}
}
} catch(Exception ex){
} finally{
cur.close();
db.close();
}
}
}
return fileInfo;
}
示例15: getAllSharedMessage
import android.database.Cursor; //導入方法依賴的package包/類
public List<SharedMessage> getAllSharedMessage(boolean isAll, boolean isPullRefresh, String time, int count) {
List<SharedMessage> list = null;
if (mDatabase.isOpen()) {
int id = getIDFromTime(time);
String sql;
String uid = UserManager.getInstance().getCurrentUserObjectId();
if (isPullRefresh) {
if (isAll) {
sql = "SELECT * from " + SHARED_TABLE + " WHERE " + _ID + " >" + id + " ORDER BY " + _ID + " DESC LIMIT "
+ count;
} else {
sql = "SELECT * from " + SHARED_TABLE + " WHERE " + _ID + " > " + id + " AND " + SHARED_BELONG_ID + " =?" + " ORDER BY " + _ID + " DESC LIMIT "
+ count;
}
} else {
if (isAll) {
sql = "SELECT * from " + SHARED_TABLE + " WHERE " + _ID + " < " + id + " ORDER BY " + _ID + " DESC LIMIT "
+ count;
} else {
sql = "SELECT * from " + SHARED_TABLE + " WHERE " + _ID + " > " + id + " AND " + SHARED_BELONG_ID + " =?" + " ORDER BY " + _ID + " DESC LIMIT "
+ count;
}
}
LogUtil.e("查詢數據庫中所有說說的sql語句" + sql);
Cursor cursor = null;
if (isAll) {
cursor = mDatabase.rawQuery(sql, null);
} else {
cursor = mDatabase.rawQuery(sql, new String[]{uid});
}
if (cursor != null) {
SharedMessage shareMessage;
list = new ArrayList<>();
while (cursor.moveToNext()) {
shareMessage = new SharedMessage();
shareMessage.setContent(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_CONTENT)));
shareMessage.setVisibleType(cursor.getInt(cursor.getColumnIndexOrThrow(SHARED_VISIBLE_TYPE)));
shareMessage.setBelongId(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_BELONG_ID)));
shareMessage.setInVisibleUserList(CommonUtils.string2list(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_INVISIBLE_USER))));
shareMessage.setLikerList(CommonUtils.string2list(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_LIKER))));
shareMessage.setMsgType(cursor.getInt(cursor.getColumnIndexOrThrow(SHARED_MSG_TYPE)));
shareMessage.setCreateTime(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_CREATE_TIME)));
shareMessage.setObjectId(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_ID)));
shareMessage.setImageList(CommonUtils.string2list(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_IMAGE_URL))));
shareMessage.setCreateTime(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_CREATE_TIME)));
shareMessage.setSeverCreateTime(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_SEVER_CREATE_TIME)));
shareMessage.setAddress(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_ADDRESS)));
shareMessage.setUrlTitle(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_URL_TITLE)));
shareMessage.setUrlList(CommonUtils.string2list(cursor.getString(cursor.getColumnIndexOrThrow(SHARED_URL))));
list.add(shareMessage);
}
if (!cursor.isClosed()) {
cursor.close();
}
LogUtil.e("查詢得到的說說大小為" + list.size());
LogUtil.e("具體的說說消息如下");
for (SharedMessage message :
list) {
LogUtil.e(message);
}
}
}
return list;
}