Android11URIusage(file://content://)的问题
创始人
2024-08-20 12:00:08
0

在Android 11中,应用程序无法直接访问文件系统中的文件,而是必须通过相应的URI来访问。此外,应用程序使用的URI类型应该是标准的content://类型而不是file://类型。

以下是使用content URI来读取文件的示例代码:

// Create a ContentResolver instance ContentResolver cr = getContentResolver();

// Define the URI for the file to be read Uri uri = Uri.parse("content://com.example.app.provider/file/sample.txt");

// Open a stream to read the file InputStream is = cr.openInputStream(uri);

// Read the content of the file byte[] buffer = new byte[1024]; int bytesRead = is.read(buffer); while (bytesRead != -1) { // Process the read data ...

// Read the next chunk of data
bytesRead = is.read(buffer);

}

// Close the stream is.close();

注意,上述内容提供商URI的格式必须为'content://authority/path”格式,其中authority是应用程序的包名。

通过这种方式使用URI,应用程序就可以在不访问文件系统的情况下读取文件。

相关内容

热门资讯

盘点一款!wepower德州设... 盘点一款!wepower德州设置,governorofpoker3有挂,详细教程(有挂介绍)-哔哩哔...
透明挂透视!(wePOke)软... 透明挂透视!(wePOke)软件透明挂,扑克王辅助工具,详细教程(有挂规律)-哔哩哔哩;wePOke...
玩家必看分享!(wepOkE)... 《wepOkE软件透明挂》是一款多人竞技的wepOkE辅助透视游戏,你将微扑克对手来到同一个战场,为...
专业讨论!德州扑克ai机器人,... 《专业讨论!德州扑克ai机器人,(wepOkE)软件透明挂,详细教程(有挂透明)-哔哩哔哩》 德州扑...
透视ai代打!德州ai辅助神器... 透视ai代打!德州ai辅助神器下载,pokermaster有外挂,详细教程(有挂技巧)-哔哩哔哩;玩...
玩家必看教程!poker有外挂... 玩家必看教程!poker有外挂,aa poker有外挂,详细教程(有挂规律)-哔哩哔哩;人气非常高,...
透明辅助!(wePOke)软件... 此外,数据分析德州(wePOke)辅助神器app还具备辅助透视行为开挂功能,通过对客户wePOke透...
总算了解!线上wpk到底有外挂... 总算了解!线上wpk到底有外挂,鱼扑克app ai,详细教程(有挂规律)-哔哩哔哩1、点击下载安装,...
必备攻略!轰趴大菠萝十三水有外... 必备攻略!轰趴大菠萝十三水有外挂,(wepoke)软件透明挂,详细教程(有挂介绍)-哔哩哔哩;原来确...
2024教程!(wepOke)... 2024教程!(wepOke)软件透明挂,wepower有辅助器,详细教程(有挂教学)-哔哩哔哩准备...