Hello I am pretty new with SQLite and I am trying to deal with some database manipulation in my project.
I have a table with almost 4000 rows and this is the format of every row:
problem_id (string)
problem_no (string)
problem_title (string)
dacu (int)
I need to query a bunch of problem_no based on the problem_id. The quantity of query is almost 1000 at a time. So I wrote a query code like this:
Set<Integer> getProblemsTitle(HashSet<String> problemsIDs) {
        SQLiteDatabase db = this.getReadableDatabase();
        HashSet<Integer> problemNo = new HashSet<Integer>();
        Cursor cursor = null;
        for (Iterator<String> iterator = problemsIDs.iterator(); iterator.hasNext();) {
            cursor = db.query(CommonUtils.PROBLEM_TABLE, new String[] {
                    CommonUtils.KEY_PROBLEM_NO },
                    CommonUtils.KEY_PROBLEM_ID + "=?",
                    new String[] { iterator.next() }, null, null, null, null);
            if (cursor != null && cursor.moveToFirst()) {
                problemNo.add(cursor.getInt(0));
            }
            cursor.close();
        }
        db.close();
        Set<Integer> set = new TreeSet<Integer>(problemNo);
        return set;
    }
I know this is not a optimized snippet. And I need to optimize it a lot to reduce the execution time of the query. I did it inside AsyncTask but it is taking too much time.
How can I do this efficiently with faster performance?
 
     
     
     
     
    