且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

cursor.getString返回带有有效uri的null

更新时间:2023-11-26 17:33:22

A Uri is not necessarily a File. The code that you are using to try to get a File for a Uri was never reliable and will not work much going forward.

请使用ContentResolver和类似openInputStream()getType()的方法适当地使用Uri.本质上,您使用Uri的方式与访问Web服务器的URL的方式相同,并且出于相同的原因:ContentProvider浮出水面的内容不需要来自普通的您的应用可以访问的内容.

Please consume the Uri appropriately, using a ContentResolver and methods like openInputStream() and getType(). In essence, you treat a Uri the same way that you would a URL to a Web server, and for much the same reason: there is no requirement for the content surfaced by a ContentProvider to be coming from an ordinary File that your app can access.