如何向 TextToSpeech/MediaPlayer 授予应用程序内部存储的读/写权限?
如何向 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有两个选择。
更好的方法是创建一个
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 associatedcontent://
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()
andMODE_WORLD_READABLE
.