我的应用允许用户在 Android设备上选择文件。我的应用如何在 Android 上使用 Digiwack File Utilities ?
答案 0 :(得分:0)
在活动代码中,以这种方式调用它:
Intent in = new Intent("com.digiwack.util.FileSelect");
in.putExtra("currFolder",Environment.getExternalStorageDirectory().toString());
in.putExtra("operation",0); //indicates "select" operation
//in.putExtra("operation", 1); //indicates "save" operation
//in.putExtra("operation", 2); //indicates "load" operation
startActivityForResult(in, 1); //or any result-code will do
在活动的onActivityResult()
方法中,添加此部分:
if (resultCode==RESULT_OK && requestCode==yourRequestCode) {
String filename = data.getExtras().getString("selectedFile");
if (filename!=null) {
//user selected a file
File yourFile = new File(filename);
//use yourFile as your app see's fit from here on out
}
}