For my android app I'm using a json file to inflate the app with content.
If I open the file from the assets folder, everything works fine. I'm opening the file simply by:
InputStream stream = getAssets().open("myfile.json");
Now I've placed the same file on a server. How should I get this file from an url? For example: http://myurl.com/myfile.json
I've tried the following:
BufferedInputStream stream = null;
try {
URL fileURL = new URL("http://myurl.com/myfile.json");
URLConnection connection = fileURL.openConnection();
connection.connect();
stream = new java.io.BufferedInputStream(connection.getInputStream());
} catch (Exception e) {
Log.e("MY_LOG_TAG", "I got an error", e);
}
It's not working, I'm recieving a 'Permission Denied' error. But the file is accessible. How to do this properly?