error:no such coloumn while getting media files

in my music player i want to get songs from album,but it gives me error in the logs.please explain me this error why this occurs.i saw all the previous question on stackoverflow about this problem but couldnt understand,please help.

public void getAlbumsLists() {
final Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;
_id = MediaStore.Audio.Albums._ID;
final String album_name = MediaStore.Audio.Albums.ALBUM;
final String artist = MediaStore.Audio.Albums.ARTIST;
tracks = android.provider.MediaStore.Audio.Albums.NUMBER_OF_SONGS;
final String data=MediaStore.Audio.Media.DATA;
final String id1=MediaStore.Audio.Media._ID;
final String tit=MediaStore.Audio.Media.TITLE;
final String nam=MediaStore.Audio.Media.DISPLAY_NAME;
final String typ=MediaStore.Audio.Media.MIME_TYPE;
final String[] columns = {_id, album_name, artist, tracks,data,id1,tit,nam,typ};

cursor = getContext().getContentResolver().query(uri, columns,null, null, null);
if (cursor != null && cursor.moveToFirst()&&cursor.getCount()>0)
do {
int x=cursor.getColumnCount();
String id = (cursor.getString(cursor.getColumnIndex(_id)));
String name = cursor.getString(cursor.getColumnIndex(album_name));
String artist2 = cursor.getString(cursor.getColumnIndex(artist));
String nr = cursor.getString(cursor.getColumnIndex(tracks));
String data1=cursor.getString(cursor.getColumnIndexOrThrow(data));
String id2=cursor.getString(cursor.getColumnIndex(id1));
String title=cursor.getString(cursor.getColumnIndex(tit));
String name1=cursor.getString(cursor.getColumnIndex(nam));
String type=cursor.getString(cursor.getColumnIndex(typ));
albumInfo s = new albumInfo(id, name, artist2, nr,data,id2,title,name1,type);
} while (cursor.moveToNext());

if (cursor != null) {

this is logcat

android.database.sqlite.SQLiteException: no such column: data (code 1): , while compiling: SELECT _id, album, artist, numsongs, duration, _id, title, _display_name, mime_type FROM album_info at android.database.DatabaseUtils.readExceptionFromParcel( at android.database.DatabaseUtils.readExceptionFromParcel( at android.content.ContentProviderProxy.query( at android.content.ContentResolver.query( at android.content.ContentResolver.query( at android.content.ContentResolver.query( at layout.BlankFragment.getAlbumsLists( at layout.BlankFragment.onCreateView(

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by edgar.murphy
4 hours ago
Last post by ewill
15 minutes ago
Last post by jalen.howe
4 hours ago
Last post by easton.lindgren
2 hours ago
Last post by hboehm
2 hours ago
Last post by wade.reinger
2 hours ago
Last post by vokeefe
1 hour ago