I have the following intent:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("text/*");
startActivityForResult(intent, DBOpenHelper.REQUEST_CODE_RESTORE);
The intent allows the user to select a text file from a number of options. It works fine with local storage and Dropbox for example, and in both cases I can get the file from as follows:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if ((requestCode == DBOpenHelper.REQUEST_CODE_RESTORE)
&& (resultCode == Activity.RESULT_OK)) {
restoreFile = new File(data.getData().getPath());
restoreFileName = restoreFile.getName();
}
}
Local storage works fine and Dropbox will copy a local copy of the file to the SD card and return the correct path. The problem is that if the user to selects files from Google Drive. When they use Google Drive, data.getData().getPath() returns something like: "/document/acc=1;doc=195" instead of returning the path to the locally stored file. How do I have Google Drive download the file and return the path? I want to allow the user to select from any file storage option they have available.