Uri的字符串是encode过的,直接用new File(uri.toString())肯定是个不存在的文件,用new File(uri.getPath())可以获取正确的目录
在vivo手机上就出问题了,uri.getPath()返回null,导致new File空指针崩溃了,vivo上uri.toString()返回的就是其他手机上uri.getPath()
也就是uri.getPath()先判空,空了用uri.toString(),再判断文件是否存在
Uri的字符串是encode过的,直接用new File(uri.toString())肯定是个不存在的文件,用new File(uri.getPath())可以获取正确的目录
在vivo手机上就出问题了,uri.getPath()返回null,导致new File空指针崩溃了,vivo上uri.toString()返回的就是其他手机上uri.getPath()
也就是uri.getPath()先判空,空了用uri.toString(),再判断文件是否存在