How to get file name from file path in android

后端 未结 10 2563
清歌不尽
清歌不尽 2020-12-08 06:13

I want to get file name from sdcard file path. e.g. :/storage/sdcard0/DCIM/Camera/1414240995236.jpg I want get 1414240995236.jpg I have written the code to fe

10条回答
  •  执笔经年
    2020-12-08 06:43

    I think you can use substring method to get name of the file from the path string.

    String path=":/storage/sdcard0/DCIM/Camera/1414240995236.jpg"; 
    // it contains your image path...I'm using a temp string...
    String filename=path.substring(path.lastIndexOf("/")+1);
    

提交回复
热议问题