get the filename (image in phone storage /download folder)

后端 未结 2 1272
迷失自我
迷失自我 2021-01-28 02:43

downloaded image shows uri shown below dat=content://com.android.providers.downloads.documents/document/22

while a get filename ==>22 is shown as filename w

2条回答
  •  -上瘾入骨i
    2021-01-28 03:36

    You can get file name using this method

    public String getName(String filename) {
        if (filename == null) {
            return null;
        }
        int index = filename.lastIndexOf('/');
        return filename.substring(index + 1);
    }
    

    In this message pass your URI as an argument

    getName(uri.toString());
    

提交回复
热议问题