lundi 29 février 2016

SQLiteOpenHelper shows error

I want to count number of tables saved in the database by giving some parameters. But it is showing error message

"The method query(boolean, String, String[], String, String[], String,
String, String, String, CancellationSignal) in the type SQLiteDatabase is not applicable for the arguments (boolean, String, String[], String, String, String, String[], null, null, null, null)" what might be the reason?

Here's the method in my helper class:

public int fetchBatches(String jobId, String jobName, String jobType) {

 String columnName = TableClass.COLUMN_JOB_ID, columnValue = jobId,  
 columnJobName = TableClass.COLUMN_JOB_NAME, columnJobValue = jobName, 
            columnJobType =  TableClass.COLUMN_JOB_TYPE, columnJobTypeValue  
  = jobType;

    if (jobId.equalsIgnoreCase("")) {
        columnName = TableClass.COLUMN_JOB_ID;
        columnValue = jobId;
        columnJobName = TableClass.COLUMN_JOB_NAME;
        columnJobValue = jobName;
        columnJobType =  TableClass.COLUMN_JOB_TYPE;
        columnJobTypeValue = jobType;
    }

    Cursor cursor = null;
    SQLiteDatabase database = getReadableDatabase();
    cursor = database.query(true, TableClass.TABLE_PRODUCTS,   //showing 
//error here
            new String[] { TableClass.COLUMN_BATCH }, columnName + " =? and ", columnJobName + " =? and ", columnJobType + "=?",
            new String[] { columnValue,columnJobValue,columnJobTypeValue }, null, null, null, null);


    cursor = database.query(TableClass.TABLE_PRODUCTS,
            null, columnJobType + " =? and " +columnName +" =? ",new String[] 
                    { columnJobTypeValue,columnValue }, null, null, null);

    if (cursor != null) {
        int count = cursor.getCount();
        if (cursor != null) {
            cursor.close();
            database.close();
        }
        return count;
    } else {
        return 0;
    }
}

Aucun commentaire:

Enregistrer un commentaire