在Google-Chrome-ARC上本地文件访问? [英] local file access on Google-Chrome-ARC?
问题描述
有什么方法可以在ARC上实现本地文件访问吗?据我了解,Chrome是沙盒存储,因此访问将很困难,但是似乎已定义的android数据目录可能具有用于文件访问的特定文件夹?
Is there any way to implement local file access on ARC? As i understand Chrome is sandboxed, so access would be hard, but it seems that the defined android data directory could have a specific folder used for file access?
推荐答案
是的,ARC上的应用程序已沙盒化,无法访问本地文件系统.
Yes, application on ARC is sandboxed and unable to access to local file system.
但是,您可以通过以下特定意图启动Activity来访问本地文件系统上的文件:ACTION_GET_CONTENT用于读取文件,而ACTION_SEND用于保存文件.
However, you can access to the file on your local file system by starting Activity with specific Intent: ACTION_GET_CONTENT for reading file and ACTION_SEND for saving file.
例如如果您要从本地文件系统打开图像文件,
e.g. If you would like to open image file from your local file system,
private static int REQUEST_CODE = 5;
private void requestImageFile() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, REQUEST_CODE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
ImageView imgView = new ImageView(this);
imgView.setImageURI(data.getData());
setContentView(imgView);
}
}
这篇关于在Google-Chrome-ARC上本地文件访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!