如何向 TextToSpeech/MediaPlayer 授予应用程序内部存储的读/写权限?

发布于 2024-12-29 18:48:39 字数 280 浏览 6 评论 0原文

如何向 TextToSpeech/MediaPlayer 授予应用程序内部存储的读/写权限?

当我尝试将文件存储在应用程序的内部存储中(对于像 /data/data/my.mycode.mydata/ 这样的文件夹)时,TextToSpeech.synthesizeToFile 返回 -1

当我授予权限时,它适用于 SD 卡。我认为我收到错误(返回值 -1 ),因为 TextToSpeech/MediaPlayer 没有创建内部存储文件的权限。

我如何提供它?可能通过manifest.xml?

How do I grant Read/Write Permissions to internal storage of my application to TextToSpeech/MediaPlayer?

TextToSpeech.synthesizeToFile return -1 when I attempt to store file in internal storage of application ( for folder like /data/data/my.mycode.mydata/ )

It works for SD card when I give permission for it. I think I get error ( return value -1 ) since TextToSpeech/MediaPlayer does not have permission for internal storage file creation.

How do I provide it? probabally through manifest.xml?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2025-01-05 18:48:39

你有两个选择。

更好的方法是创建一个 ContentProvider 来为您的文件提供服务,并在使用“TextToSpeech”时使用关联的 content:// Uri 值/媒体播放器”。 这是一个示例项目,演示了一个提供 PDF 文件的应用程序,从项目资源中复制出来,以便通过设备上的 PDF 查看器查看。

或者,使用 创建文件openFileOutput()MODE_WORLD_READABLE

You have two options.

The better approach is to create a ContentProvider that will serve your files, and use the associated content:// Uri values when working with "TextToSpeech/MediaPlayer". Here is a sample project demonstrating an app serving up a PDF file, copied out of the project's assets, to be viewed by a PDF viewer on the device.

Alternatively, create the file using openFileOutput() and MODE_WORLD_READABLE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文