Content URI is wrong when app restart

I used a database to store the URI for an mp3 file, but when I restart the app, trying to set the source returns an error saying that it failed to load, and when i get the URI again its still the same though
URI was:


but when i restart the app and try to play that it gives this:

and if i clear the database and upload the song in again, it gets this same URI, and now it works? how do i fix this?

In the near future (Android 10+, Android 11) there are only two directories that you can store files in:

  1. App Specific Directory (aka ASD) - currently requires Taifun's File Extension to create it
  2. App Private Directory (aka Assets) - the directory were the in-App files are stored. However, most music mp3 files are too big for the App Private Directory.

Note, re Error 701. The % delimiter characters could be the cause of the issue - they work with HTML, one or more of them may not work with Android/App Inventor so you could decipher those in the App to use regular UTF-8 characters.

Content uri is not same always so you should use file path.

Can i use the file path as the argument for Player.Source

Yes you can, but as I explained, the file should be stored in the App Specific Directory. If the App is only for your use and will only be used on Android v10 and below, you can store your file where it is now or anywhere else that's convenient.

Note, some of the % codes are still inadvisable in a file path - %3A for example is a colon, %5B a square bracket, so a straight conversion may not yield a valid path.

I tried setting the file path instead for the source and this happened

Do you know the issue here?

Code is

and the player code is

That is because of unnecessary [] in the path.

You can hard-code the path in a single Text Block.......... also simplify and shorten the file name.

it has to work for any name, its an mp3 player after all

You know better than us then right?

er no im 15 and very much retarded

The point about the filename length and simplification

  1. A long filename, as part of the path, can make the path too long
  2. It's easier to make typographical mistakes when names are long and or complex

even something like /storage/emulated/0/Downloads/ADAMAS.mp3 didnt work

It does have to be a full path and unfortunately we can't necessarily tell you what the path might be since different device manufactures organize the directories differently, including folder names. How are does the file get to where it is in the first place? Perhaps the easiest way to check the path is via your PC - USB cable connection.

use a relative path, which is /Downloads/ADAMAS.mp3 or a full path, which is file:///storage/emulated/0/Downloads/ADAMAS.mp3

also you have to replace spaces by %20 in the filename, see my jukebox example here App Inventor Extensions: File | Pura Vida Apps

the assets are always read only, see also the following link


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.