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,应用程序就可以在不访问文件系统的情况下读取文件。

相关内容

热门资讯

透视系统!aapoker怎么控... 透视系统!aapoker怎么控制牌(透视)万能辅助器(竟然真的有挂);aapoker怎么控制牌辅助器...
透视app!wejoker辅助... 透视app!wejoker辅助软件,wepoker透视脚本免费app(详细辅助软件视频)1、全新机制...
透视免费!aapoker辅助插... 透视免费!aapoker辅助插件工具(透视)辅助(真是真的是有挂)1、aapoker辅助插件工具ai...
透视规律!wepokerplu... 透视规律!wepokerplus脚本,wepoker怎么拿到好牌(详细祈福有用)1、任何wepoke...
透视游戏!aapoker辅助软... 透视游戏!aapoker辅助软件合法吗(透视)透视方法(其实有挂);1.aapoker辅助软件合法吗...
透视苹果版!wepoker永久... 透视苹果版!wepoker永久免费脚本,wepokerplus到底是挂了吗(详细htx矩阵辅助)1、...
透视黑科技!aapoker透视... 透视黑科技!aapoker透视怎么用(透视)透视插件(总是真的是有挂)1)aapoker透视怎么用辅...
透视了解!wepoker辅助透... 透视了解!wepoker辅助透视,wepoker轻量版有透视吗(详细智能辅助插件)1、让任何用户在无...
透视挂透视!aapoker插件... 透视挂透视!aapoker插件下载(透视)透视插件(果然是有挂)1、全新机制【aapoker插件下载...
透视了解!wepoker能不能... 透视了解!wepoker能不能透视,wejoker透视方法(详细可以提高运气)亲,关键说明,wepo...