android如何根据文件路径获取文件信息

手机里有个文件,知道具体路径xx/xx/xx/xx/1.mp3
怎么通过路径获取1.mp3的所有文件信息

mp3的文件信息可以通过Mediaplayer类的相关方法获取

不知道你说的文件信息是什么,是文件的大小、属性、创建日期这些,还是mp3的id3信息,比如曲目、轨道、艺术家、音频的时间等。

这是id3的获取: https://www.jianshu.com/p/e368517ec7b9

读取文件本身的属性,用file类,比如

File f=new File(path); //文件名
//Date time=new Date(f.lastModified());
if(f.exists()){//
System.out.println("File Exist.");
}
long time=f.lastModified();
SimpleDateFormat formatter = new

SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String result=formatter.format(time); //读取文件修改时间

利用String 类中的lastIndexOf()方法 , 分别获得"/" 和"."的索引,之后利用截取子串;substring(start , end)方法得到文件名。