Java Code Examples for android.database.Cursor.isClosed()

The following are Jave code examples for showing how to use isClosed() of the android.database.Cursor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: OSchina_resources_android   File: DBHelper.java   Source Code and License Vote up 6 votes
/**
 * 判断数据表是否存在
 *
 * @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;
}
 
Example 2
Project: Cable-Android   File: AbstractCursorLoader.java   Source Code and License Vote up 6 votes
@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();
  }
}
 
Example 3
Project: letv   File: DownloadManager.java   Source Code and License Vote up 6 votes
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;
}
 
Example 4
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 5 votes
/**
 * 获取所有的群结构表
 *
 * @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;
}
 
Example 5
Project: filepicker   File: OtherFilePickerModel.java   Source Code and License Vote up 5 votes
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;
}
 
Example 6
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 5 votes
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;
}
 
Example 7
Project: letv   File: DownloadDBDao.java   Source Code and License Vote up 5 votes
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;
    }
}
 
Example 8
Project: Android-Bubble-Game   File: DataBaseHelper.java   Source Code and License Vote up 5 votes
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";
}
 
Example 9
Project: Notepad-For-Android   File: DisplayNote.java   Source Code and License Vote up 5 votes
@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);
        }
    }
}
 
Example 10
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 5 votes
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;
}
 
Example 11
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 5 votes
/**
 * 判断最近消息列表中是否有该用户的消息
 *
 * @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;
}
 
Example 12
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 5 votes
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;
}
 
Example 13
Project: KTools   File: ContactsLoaderCallback.java   Source Code and License Vote up 5 votes
@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();

}
 
Example 14
Project: prada   File: UploadLogDBHelper.java   Source Code and License Vote up 5 votes
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;
}
 
Example 15
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 4 votes
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;
}
 
Example 16
Project: OSchina_resources_android   File: DBHelper.java   Source Code and License Vote up 4 votes
public <T> List<T> get(Class<T> cls, String where, String orderColumn, String orderType, int limit, int offset) {
    String tableName = getTableName(cls);
    if (!isExist(tableName))
        return null;
    List<T> list = new ArrayList<>();
    SQLiteDatabase db ;
    Cursor cursor = null;
    try {
        db = getReadableDatabase();
        String sql = String.format("SELECT * from %s", tableName);
        String whereAre = TextUtils.isEmpty(where) ? null : " " + where;
        String orderBy = TextUtils.isEmpty(orderColumn) ? null : String.format(" ORDER BY %s %s", orderColumn, orderType);
        String limitStr = limit == 0 ? null : String.format(" limit %s offset %s", String.valueOf(limit), String.valueOf(offset));
        StringBuilder sb = new StringBuilder();
        sb.append(sql);
        sb.append(TextUtils.isEmpty(limitStr) ? "" : limitStr);
        sb.append(TextUtils.isEmpty(whereAre) ? "" : whereAre);
        sb.append(TextUtils.isEmpty(orderBy) ? "" : orderBy);

        sql = sb.toString();
        cursor = db.rawQuery(sql, null);
        Field[] fields = cls.getDeclaredFields();
        while (cursor.moveToNext()) {
            T t = cls.newInstance();
            for (Field field : fields) {
                field.setAccessible(true);
                String name = "";
                if (field.isAnnotationPresent(Column.class))
                    name = field.getAnnotation(Column.class).column();
                else if (field.isAnnotationPresent(PrimaryKey.class))
                    name = field.getAnnotation(PrimaryKey.class).column();
                if (!TextUtils.isEmpty(name)) {
                    Class<?> type = field.getType();
                    if (type.equals(int.class)) {
                        field.set(t, cursor.getInt(cursor.getColumnIndex(name)));
                    } else if (type.equals(String.class)) {
                        field.set(t, cursor.getString(cursor.getColumnIndex(name)));
                    } else if (type.equals(long.class)) {
                        field.set(t, cursor.getLong(cursor.getColumnIndex(name)));
                    } else if (type.equals(float.class)) {
                        field.set(t, cursor.getFloat(cursor.getColumnIndex(name)));
                    } else if (type.equals(double.class)) {
                        field.set(t, cursor.getDouble(cursor.getColumnIndex(name)));
                    }
                }
            }
            list.add(t);
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
    }
    return list;
}
 
Example 17
Project: AndiCar   File: DBAdapter.java   Source Code and License Vote up 4 votes
/**
 * check update preconditions
 *
 * @return -1 if the row can be deleted, an error code otherwise. For error
 * codes see errors.xml
 */
private int canUpdate(String tableName, ContentValues content, long rowId) {

    String checkSql;
    Cursor checkCursor;
    if (tableName.equals(TABLE_NAME_UOM)) {
        if (content.containsKey(DBAdapter.COL_NAME_GEN_ISACTIVE) && content.getAsString(DBAdapter.COL_NAME_GEN_ISACTIVE).equals("N")) {
            //check if the uom are used in an active car definition
            checkSql = "SELECT * " +
                        " FROM " + TABLE_NAME_CAR +
                        " WHERE " + COL_NAME_GEN_ISACTIVE + " = 'Y' " +
                                "AND (" + COL_NAME_CAR__LENGTH_UOM_ID + " = " + rowId +
                                        " OR " + COL_NAME_CAR__FUEL_UOM_ID + " = " + rowId + ") " +
                        " LIMIT 1";
            checkCursor = mDb.rawQuery(checkSql, null);
            if (checkCursor.moveToFirst()) { //record exists
                checkCursor.close();
                return R.string.error_025;
            }
            if (!checkCursor.isClosed()) {
                checkCursor.close();
            }
        }
    }
    else if (tableName.equals(TABLE_NAME_CURRENCY)) {
        if (content.containsKey(DBAdapter.COL_NAME_GEN_ISACTIVE) && content.getAsString(DBAdapter.COL_NAME_GEN_ISACTIVE).equals("N")) {
            //check if the currency are used in an active car definition
            checkSql = "SELECT * " + "FROM " + TABLE_NAME_CAR + " " + "WHERE " + COL_NAME_GEN_ISACTIVE + " = 'Y' " + "AND " + COL_NAME_CAR__CURRENCY_ID
                    + " = " + rowId + " " + "LIMIT 1";
            checkCursor = mDb.rawQuery(checkSql, null);
            if (checkCursor.moveToFirst()) { //record exists
                checkCursor.close();
                return R.string.error_026;
            }
            if (!checkCursor.isClosed()) {
                checkCursor.close();
            }
        }
    }
    return -1;
}
 
Example 18
Project: Android-Wear-Projects   File: DbCursorLoader.java   Source Code and License Vote up 4 votes
private void onReleaseResources(Cursor cursor){
    if (!cursor.isClosed()){
        cursor.close();
    }
}
 
Example 19
Project: Cable-Android   File: AbstractCursorLoader.java   Source Code and License Vote up 4 votes
@Override
public void onCanceled(Cursor cursor) {
  if (cursor != null && !cursor.isClosed()) {
    cursor.close();
  }
}
 
Example 20
Project: GroupingMessages   File: DatabaseBridge.java   Source Code and License Vote up 4 votes
private static List<Map<String, String>> getFromConfigs(Context context, String selection, String[] selectArgs) {

        List<Map<String, String>> configs = new ArrayList<>();

        initializeDb(context);
        Cursor cursor = db.query(
                DatabaseContract.Config.TABLE_NAME,           // The table to query
                DatabaseContract.Config.KEY_ARRAY,            // The columns to return
                selection,                                      // The columns for the WHERE clause
                selectArgs,                                     // The values for the WHERE clause
                null,                                           // don't group the rows
                null,                                           // don't filter by row groups
                DatabaseContract.Config.DEFAULT_SORT_ORDER    // The sort order
        );

        if (cursor != null && cursor.moveToFirst()) {
            int indexId = cursor.getColumnIndexOrThrow(DatabaseContract.Config._ID);
            int indexName = cursor.getColumnIndexOrThrow(DatabaseContract.Config.KEY_NAME);
            int indexValue = cursor.getColumnIndexOrThrow(DatabaseContract.Config.KEY_VALUE);
            Map<String, String> configTemp;

            while (!cursor.isAfterLast()) {
                configTemp = new HashMap<>();

                final long configId = cursor.getLong(indexId);
                final String configName = cursor.getString(indexName);
                final String configValue = cursor.getString(indexValue);

                configTemp.put(DatabaseContract.Config._ID, String.valueOf(configId));
                configTemp.put(DatabaseContract.Config.KEY_NAME, configName);
                configTemp.put(DatabaseContract.Config.KEY_VALUE, configValue);
                configs.add(configTemp);
                cursor.moveToNext();
            }
        } else {
            Log.e(GM_CURSOR, CURSOR_IS_NULL + "getFromConfigs");
        }

        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }

        unInitializeDb();

        return configs;
    }