Skip to content Skip to sidebar Skip to footer

How To Get Field Value Instead Of Column Name?

I want to fill a list with data from a cursor this way: myCursor = myDBA.getAllCompanies(); startManagingCursor(myCursor); myListAdapter = new SimpleCursorAdap

Solution 1:

Did you tried to move the cursor to the first index cursor.moveToFirst(); then do cursor.getString(columnIndex); ?

There is another way, create one List or array that will hold the values from the cursor, access all the data inside it by iterating through the cursor

while(cursor.isAfterLast()==false)
{
  list.add(cursor.getString(thestringcollumnindex);
 cursor.moveToNext();
}

then just do

iconName=list.get(columnindex);

This solution is not the best but how ever serves the purpose.

Solution 2:

Did you try?

cursor.getString(cursor.getColumnIndex("column_name"));

it will get you the string from the column_name

Post a Comment for "How To Get Field Value Instead Of Column Name?"