Cursor getString was added in API Level 1
Returns the value of the requested column as a String.
The result and whether this method throws an exception when the column value is null or the column type is not a string type is implementation-defined.
Parameters: columnIndex the zero-based index of the target column.
Returns: the value of that column as a String.
1. Move the Cursor to the First Row of a Cursor named myCursor.
2. Add the below line right after if (myCursor.moveToFirst()) { where the // myCursor moved to the first record comment is located. This will save the contents of the Display name of an audio file to a string named myString.
String myString = cursor.getString(cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.DISPLAY_NAME));
Resources:
http://developer.android.com/reference/android/database/Cursor.html#getString(int)
String myString = cursor.getString(cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.DISPLAY_NAME));
3. Compile and run!
4. Other column names for MediaStore Audio files are listed here.
Resources:
http://developer.android.com/reference/android/database/Cursor.html#getString(int)