【发布时间】:2015-08-29 03:12:52
【问题描述】:
它需要生成一个临时文件并通过其他可能的应用程序共享:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filePath)));
startActivity(Intent.createChooser(intent, "share file");
但是当与其他应用程序共享时,文件似乎无法访问。这是因为文件保存在应用程序内部目录中。
所以它需要保存到属于这个应用程序的目录(所以它会在卸载时被删除,最好是在一个临时目录中,以便操作系统可以清理它),并且其他应用程序也可以访问它。
看到 getExternalCacheDir()、getExternalFilesDir()、getExternalStorageDirectory()、getExternalStoragePublicDirectory(),不确定哪种方法适合这种情况。有人有建议吗?谢谢!
【问题讨论】:
标签: android file local-storage share