I am trying to get the file path of a file from a file picker.
My problem is, that when I output the file path in text form, I get the following output:
file:/
storage/emulated/~rest_of_path~
I assume, to access the file, the path should begin something like this:
file:///
storage/emulated/~rest_of_path~
or at least file://
Why do I only get file:/
i.e a single slash.
The code in charge for getting the file path:
...
File fileToImport = new File(actualfilepath);
String tempPath = uri.getPath();
if (tempPath.contains("//")){
tempPath = tempPath.substring(tempPath.indexOf("//")+1);
}
if ( actualfilepath.equals("") || actualfilepath.equals(" ")) {
fileToImport = new File(tempPath);
}else {
fileToImport = new File("file://"+actualfilepath);
}
// TODO: 2019-06-04
functionforfile(fileToImport)
filePath.setText(fileToImport.toString());
The text view for the code filePath.setText(fileToImport.toString());
shows me the file path for debug purpose only
if fileToImport = new File("file://"+actualfilepath);
has File("file://"actualfilepath)
instead, it outputs the file path without file://
which I understand, but why do the two //
get removed when I add "file://" + actualfilepath
How could I add the correct file:///
Thanks in advance