hehe0595
hehe0595

Reputation: 1

android detecting mp3 file in phone storage

please help me to do this project, i want to know how to detect audio files from phone storage, THANKS in advance guys :).

here is my code

  package com.example.cameraapp;

import android.os.Bundle;
import android.provider.MediaStore;
import android.app.Activity;
import android.view.Menu;
import android.widget.ListView;
public class FinalChoice extends Activity {
 ListView lv;
 Model[] modelItems;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.listview1hold);
 lv = (ListView) findViewById(R.id.listView1);


 String columns[] ={MediaStore.Audio.Playlists.Members.TITLE};
 modelItems = new Model[columns.length];



 for(int a=0; a<columns.length;a++)
 {
     modelItems[a]=new Model(columns[a], 0);
 }




 CustomAdapter adapter = new CustomAdapter(this, modelItems);
 lv.setAdapter(adapter);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
 // Inflate the menu; this adds items to the action bar if it is present.
 getMenuInflater().inflate(R.menu.main, menu);
 return true;
 }
}

this code only gives an output of a"title" with a checkbox

Upvotes: 0

Views: 391

Answers (1)

Pankaj Deshpande
Pankaj Deshpande

Reputation: 502

instead of reading MediaStore.Audio.Playlists.Members.TITLE, read the files simply by java way as dir.list(), read file name, extract extension and add those files into display list which has valid audio extension. Valid audio formats for Android can be found at http://developer.android.com/guide/appendix/media-formats.html

Upvotes: 1

Related Questions