使用Android存储访问框架编写数据的文件的最佳方法是什么?
我想使用Android存储访问框架编写一个带有数据的文件,但我面临一些问题。在以下代码中,我可以创建一个文件,但文件为空白。
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.setType("application/vnd.ms-excel");
intent.putExtra(Intent.EXTRA_TITLE,DATABASE_NAME+"_"+AppUtils.getCurrentDate()+".xls");
startActivityForResult(intent,CREATE_FILE);
如果我使用以下代码,那么我可以从onActivityResult
中获取写作访问权限,
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/vnd.ms-excel");
startActivityForResult(intent,WRITE_FILE);
以使我的无用户友好,因为用户必须创建一个文件首先,他们必须再次选择它以编写数据。我希望直接创建文件并将文件写入Android存储访问框架。有什么好方法吗?请帮忙。
I want to write a file with data using Android Storage Access Framework but I am facing some problems. in this below code I can create a file but the file is blank.
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.setType("application/vnd.ms-excel");
intent.putExtra(Intent.EXTRA_TITLE,DATABASE_NAME+"_"+AppUtils.getCurrentDate()+".xls");
startActivityForResult(intent,CREATE_FILE);
if I use this below code then I can get writing access to throw the Uri
from onActivityResult
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/vnd.ms-excel");
startActivityForResult(intent,WRITE_FILE);
it makes my app-less user-friendly because the users will have to create a file first then they have to select it again for writing data on it. I am expecting something directly to create and write the file into the Android Storage Access Framework. is there any good way to do that. please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论