How can I put a string and an integer into the same array?

Posted by Stelios M on Stack Overflow See other posts from Stack Overflow or by Stelios M
Published on 2012-04-10T17:20:01Z Indexed on 2012/04/10 17:29 UTC
Read the original article Hit count: 119

Filed under:

I have to following code. I want this to return an array e.g. arg[] that contains at arg[0] the number of the rows of my cursor and at arg[1] String(0) of my cursor. Since one is integer and the other is string I have a problem. Any ideas how to fix this?

    public String[] getSubcategoriesRow(String id){
    this.openDataBase();
    String[] asColumnsToReturn = new String[] {SECOND_COLUMN_ID,SECOND_COLUMN_SUBCATEGORIES,};
    Cursor cursor = this.dbSqlite.query(SECOND_TABLE_NAME, asColumnsToReturn, SECOND_COLUMN_SUBCATEGORIES + "= \"" + id + "\"", null, null, null, null);

    String string = cursor.getString(0);
    int count = cursor.getCount();
    String arg[] = new String[]{count, string};
    cursor.close();
    return arg;
  }

The cursor and the results and correct i just need to compine them to an array in order to return that.

© Stack Overflow or respective owner

Related posts about android