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 leffler.sylvester
2 hours ago
Last post by jsanford
4 hours ago
Last post by saige73
1 hour ago
Last post by cayla.hoppe
2 hours ago
Boost GS2
Started by prenner
Last post by connelly.america
3 hours ago
Last post by toby31
4 hours ago
Last post by uosinski
3 hours ago
Last post by saul.klein
3 hours ago
Helpp me
Started by myundt
Last post by hklocko
3 hours ago
Last post by shanel.carter
4 hours ago
Last post by eebert
2 hours ago
Last post by bechtelar.mac
1 hour ago
Last post by harvey.bashirian
59 minutes ago
Last post by viva14
1 hour ago
Last post by grimes.rudy
1 hour ago
Last post by prodriguez
1 hour ago