-1

I don't see what is wrong with my ArrayList that i get this error:

Error:(133, 17) error: incompatible types: ArrayList cannot be converted to String

i want to get all columns from table name

   public String getListOfFiltersName(){

        ArrayList<String> arrTblNames = new ArrayList<String>();
        Cursor c = mydb.rawQuery("SELECT name FROM  " + MyDatabase.tableFilters, null);

        if (c.moveToFirst()) {
            while ( !c.isAfterLast() ) {
                arrTblNames.add( c.getString( c.getColumnIndex("name")) );
                c.moveToNext();
            }
        }
        c.close();
        mydb.close();
        return  arrTblNames;
    }

1 Answer 1

3

The type of returned value arrTblNames is ArrayList but the return type of getListOfFiltersName is String Hence the error so return type of getListOfFiltersName method should be ArrayList<String> instead of String

public ArrayList<String> getListOfFiltersName(){

or preferably public List<String> getListOfFiltersName(){

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.