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


Java Cursor.isClosed方法代码示例

本文整理汇总了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;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:31,代码来源:DBHelper.java

示例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();
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:20,代码来源:AbstractCursorLoader.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:DownloadManager.java

示例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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:37,代码来源:ChatDB.java

示例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;
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:40,代码来源:OtherFilePickerModel.java

示例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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:14,代码来源:ChatDB.java

示例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;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:36,代码来源:DownloadDBDao.java

示例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";
}
 
开发者ID:UshalNaidoo,项目名称:Android-Bubble-Game,代码行数:13,代码来源:DataBaseHelper.java

示例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);
        }
    }
}
 
开发者ID:dvinfosys,项目名称:Notepad-For-Android,代码行数:33,代码来源:DisplayNote.java

示例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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:14,代码来源:ChatDB.java

示例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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:20,代码来源:ChatDB.java

示例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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:35,代码来源:ChatDB.java

示例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();

}
 
开发者ID:jiangkang,项目名称:KTools,代码行数:16,代码来源:ContactsLoaderCallback.java

示例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;
}
 
开发者ID:quanzhuo,项目名称:prada,代码行数:32,代码来源:UploadLogDBHelper.java

示例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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:68,代码来源:ChatDB.java


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