I have some Java knowledge but its very fresh. Yesterday I started learning some Java for Android and encountered a problem. Specifically I want to retrieve a decimal number from a website API for some in-app calculations. I have code that works perfectly in normal Java, but when I insert it into Android Studio it compiles but the app crashes at start. Any help would be appreciated.
Here's the number retrieval code :
        URL url = new URL("api.example.com");
    URLConnection con = url.openConnection();
    InputStream is =con.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    String line = null;
    int cont=0;
    while ((line = br.readLine()) != null) {
        cont++;
        if(cont==28){
            Dol = Double.parseDouble(line.substring(25, 31));
        }
    }
 
     
    