I'm working on an app (and yes, I'm a beginner to app development, so if you have any suggestions to use in place of the code I'm posting, then please say so). I'm trying to load an audio file to be processed later in the use of the app. but what I'm stuck with at the moment is the following. When you click on "add" it takes you to the file explorer where to need to select an audio file. Once the file is selected, the file name needs to display in a TextView. The problem I'm having is that the file name isn't being displayed correctly.
test filename: Test audio file.mp3
result in the TextView: primary%3ADownload%2FTest%20audio%20file.mp3
So its setting the entire path as the TextView with % signs etc. and I don't know why. How can I make it display only the file name correctly without the full path?
Code for opening file explorer:
Intent explorer = new Intent(Intent.ACTION_GET_CONTENT, MediaStore.Audio.Media.INTERNAL_CONTENT_URI);
startActivityForResult(explorer, SELECT_AUDIO_FILE);
Code for retrieving the filename and setting it to the TextView:
audioUri = data.getData();
File fileToProcess = new File("" + audioUri);
String audioFileName = fileToProcess.getName();
fileNameDisplay.setText(audioFileName);