I have this code for uploading a file to my application, and when the file is opened by the file manager or Dropbox or something else, the return path is correct and I can access it, I only have problems with Google Drive, it returns some path starting with βexposedβ and I cannot βdecodeβ it in any way, I searched and did not find a way, who has any ideas?
if (resultCode == Activity.RESULT_OK) { if ((data != null) && (data.getData() != null)) { final Uri filePath; if (data.getDataString().startsWith("content")) { filePath = getRealPathFromURI(getApplicationContext(), data.getData()); } else { filePath = data.getData(); } // TODO bug with google drive if (filePath.getLastPathSegment() != null) { tvSelectedFile.setText("File selected: " + filePath.getLastPathSegment()); } else { tvSelectedFile.setText("File can not be accessed, please try another way"); } } }
android google-drive-sdk android-file
Sartheris stormhammer
source share