user2529011
user2529011

Reputation: 743

Android VideoView: How do I validate an illegal character in my url?

in my android app I provide a url but it contains an apostrophe ' in the url. This breaks the link and I get a W/MediaPlayer: Couldn't open <url here> java.io.FileNotFoundException: No content providerwhen I check sure enough the link breaks next to the aforementioned character.

Here is the link:

https://foowebsite.com/videos/4/Manny's%20Awesome%20Videos/2019-05-09/92aede2e-ce54-49a4-9eca-86b3bb79fe73.mp4

Here is how I am consuming the url and modifying some of the known illegal characters.

mVideoView.setVideoPath(
        mCurrentItem.getmDownloadLink()
        .replace(" ", "%20")
        .replace("\\", "/")
        .replace("//", "/")
        .replace(":/", "://"));
//More video setup below...

My question is: how do I make the url take in that apostrophe.

Upvotes: 1

Views: 49

Answers (1)

Beyazid
Beyazid

Reputation: 1835

It's a single quote, you should use %27 in URL instead of the single quote. And you can use this.

yourString.replaceAll("'","%27");

You can look at this for URL encoding reference

Upvotes: 1

Related Questions