0

I'm a new student working on an android application. The application is almost done and works fine.

The app uses a property list to generate it's content. At this moment it uses a .plist file located in the assets folder. Ideally I want this .plist file to be retrieved from an URL. However i'm stuck on this part for a few days now.

Could you please advise me in how to realise retrieving and using the file from an URL. Any advice is welcome!

In my code we see how I currently read the .plist file. I don't think the parsing of the response is required info for my question:

public class PListHelper {
    /**
     * PlayList reader from assets
     * 
     * @return string of p-list file
     */
    public static String readPlayListFromAssets(Context context) {
        StringBuffer sb = new StringBuffer();
        BufferedReader br=null;
        try {
             br = new BufferedReader(new InputStreamReader(context.getAssets().open("restaurant.plist"))); 
            String temp;
            while ((temp = br.readLine()) != null)
                sb.append(temp);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                br.close(); // stop reading
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        Log.i("Main", "input: "+sb.toString());

        return sb.toString();
    }
Nils R.
  • 1
  • 3
  • possible duplicate of [Reading Text File From Server on Android](http://stackoverflow.com/questions/2922210/reading-text-file-from-server-on-android) – Sufiyan Ghori Dec 27 '14 at 18:52

1 Answers1

0

Have a look at URLConnection

Also, in the future, avoid using .plist as it something specific to ios and osx. By using another format (like json) you won't have to implement your own parsing.

Rares Barbantan
  • 761
  • 4
  • 9
  • Thanks for your answer. It worked like a charm! Just need to create it Async now. The reason why I use a plist is because we have to build the same app in both iOS and Android. It seemed like an easy and quick way to get the job done. Thanks again for your help! – Nils R. Dec 27 '14 at 19:21