Permission Exception when reading remote files


Last Updated:

  1. hshhbd

    hshhbd New Member This Topic's Starter

    Joined:
    Nov 4, 2010
    Messages:
    2
    Likes Received:
    0
    I was trying to read a xml file remotely but keep getting the java.net.SocketException: Permission denied exception. I tried the same thing within a normal java application and it works.

    Here is the code:
    try
    {
    URL url = new URL("http://rss.weather.com/rss/national/rss_nwf_rss.xml?cm_ven=NWF&cm_cat=rss&par=NWF_rss");
    InputStream input = url.openStream();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }

    I was doing it in a Android Emulator, maybe that's the cause?

    Thanks very much in advance for any replies.
     

    Advertisement
  2. jonbonazza

    jonbonazza Well-Known Member

    Joined:
    Jul 13, 2010
    Messages:
    1,934
    Likes Received:
    458
    Did you enable the GSM Modem when creating the AVD?
     
  3. hshhbd

    hshhbd New Member This Topic's Starter

    Joined:
    Nov 4, 2010
    Messages:
    2
    Likes Received:
    0
    Thanks for your reply. Actually I have just solved the problem. It's something to do with the manifest file. To solve the problem, the following line will need to be added.
    <uses-permission android:name="android.permission.INTERNET"/>

    This enables your android application talking to files on remote servers.
     

Share This Page

Loading...