MediaRetriever for an executor returning null
artist is only gettiing initialized value but not artistextracted using PLZ metadata suggest me wath wrong i am doing
Strng artist="";
void onCreate(){
metaRetriver1 = new MediaMetadataRetriever();
metaRetriver1.setDataSource("/storage/sdcard0/Tu+Jo+Hain.mp3");
artist=metaRetriver1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
}
+3
user5073073
source
to share
2 answers
listFiles
returns null
if file is not a directory or an I / O error occurs, so you should check for possible nulls.
Environment.getExternalStorageDirectory () already returns the path to your external storage directory. Therefore, instead of
String root_sd = Environment.getExternalStorageDirectory().toString();
file = new File( root_sd + "/external_sd" ) ;
File list[] = file.listFiles();
you can just
File list[] = Environment.getExternalStorageDirectory().listFiles();
remember from api level 19 you must add READ_EXTERNAL_STORAGE to your AndroidManifest.xml file
+1
source to share