Searching Audio Files in Android
Searching for Audio Files in Android is so much similar in Display Contact Names in Android (I suggest you to look back at the explanation for a more detailed explanation). The audio formats that Android allows are MP3, AAC, AMR.
Quick Explanation
The thing that you need here is Audio.Media.EXTERNAL_CONTENT_URI, as stated on the the contact display article, managedQuery acts like a sql call and the table this time is Audio.Media.EXTERNAL_CONTENT_URI.
Another thing you might have notice is String[] columnsToMap = new String[] {Audio.Media.TITLE , Audio.Media._ID};. These and a lot more are the columns that can be used.
Source Code
Main.java file for Searching Audio in Android
References
android.provider.MediaStore.Audio.Media
Display Contact Names in Android

Update History
Jan 17, 2012 - Visual Update
public class Main extends ListActivity {
private Cursor audioCursor;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
audioCursor = this.managedQuery(Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
startManagingCursor(audioCursor);
String[] columnsToMap = new String[] {Audio.Media.TITLE , Audio.Media._ID};
int[] mapTo = new int[] {android.R.id.text1,android.R.id.text2};
ListAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.two_line_list_item , audioCursor, columnsToMap, mapTo);
this.setListAdapter(mAdapter);
}
}
Quick Explanation
The thing that you need here is Audio.Media.EXTERNAL_CONTENT_URI, as stated on the the contact display article, managedQuery acts like a sql call and the table this time is Audio.Media.EXTERNAL_CONTENT_URI.
Another thing you might have notice is String[] columnsToMap = new String[] {Audio.Media.TITLE , Audio.Media._ID};. These and a lot more are the columns that can be used.
Source Code
Main.java file for Searching Audio in Android
References
android.provider.MediaStore.Audio.Media
Display Contact Names in Android

Update History
Jan 17, 2012 - Visual Update
No comments: