Adding data to a database cursor

android

Solution

You cannot modify an existing `Cursor` this way. You need to create the `Cursor` with the data you seek at the outset.

More likely, though, you do not need to modify the `Cursor`, but rather whatever is using the `Cursor` has to be smarter. For example, if your issue is that you cannot use a computed column in `SimpleCursorAdapter`, you need to switch to `CursorAdapter` and override `bindView()` to have the smarts you want.

Problem

Maybe I'm going about this the wrong way, but if so, please correct me. Here is the situation: I have a query which returns URI strings for ringtones stored in a database. I am trying to add a "column" to this cursor with the ringer "Title" (since this can change outside my program). I can successfully use `RingtoneManager` to get the title, but I cannot figure out how to add this "column" to the cursor data for later use. Here is what I have so far: ``` if (cursor != null) { cursor.moveToFirst(); do { String ringerTitle = getRingerTitle(cursor.getString(cursor.getColumnIndex(PoolDbAdapter.KEY_RINGER))); // How can I add ringerTitle to a new column here? } while (cursor.moveToNext()); } ```

Original source