I am trying to get all the media files from the device (Internal and SDcard).Till now I am able to get all the media files from a fixed folder of SD Card .I have gone through most of the web pages on mediastore .And i am able to get the media info.But how can I get all the audio files from the device any example will be helpful. I tried this way ` public class SongDto {
public long songId;
public String songTitle;
public String songArtist;
public String path;
public short genre;
public long duration;
public String album;
public Bitmap albumArt;
public String toString() {
return String.format("songId: %d, Title: %s, Artist: %s, Path: %s, Genere: %d, Duration %s",
songId, songTitle, songArtist, path, genre, duration);
}
and getting these value in another class name
public class Utils {
private Context _context;
// constructor
public Utils(Context context) {
this._context = context;
}
public static ArrayList<SongDto> getMusicInfos(Context context) {
ArrayList<SongDto> musicInfos = new ArrayList<SongDto>();
and now I am trying to get the the songTitle in another class
private ArrayList<SongDto> musicInfos;
private Utils utils;
private ArrayList<String> songPaths = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
utils = new Utils(this);
songPaths = utils. getMusicInfos(songTitle);
}
private void update(){
ArrayAdapter<String> list=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,musicInfos.add(songTitle) );
}
}
How I can get only the desired array like array of songId ,songArtist,song duration.And where I am doing wrong .How to set the getMusicInfos method `
You can try this
and similarly you can also get the internel storage audio files by specifying INTERNEL_CONTENT_URI
I used this code to get all song data
and use this as data object
AbumArt might come as null
To fetch song id as list
and get the data from cursor. To get both internal and external storage songs list, as of now I don't have a solution.