I created a Async-Download-Class to download JSON-Code from an interface-website. It does actually work, but sometimes it breaks and in the download log I can see question marks that should be a string. I had this problem before and solved it by just increasing the buffer size but this affects the speed of the app.
As you can imagine the JSON-Reader searches for a timestamp but he cannot find one. So the error I get is a formatexception but I think this is not relevant. (Sometimes undetermined object, too)

```
10-17 18:38:11.443: D/debug(13532): {"ident":"50572","ts":"24.05.2011 07:40","content":"<inmydays> Bin ich der einzige der dachte, beim Film 1+1=10 geht es um Nerds und nicht darum, dass 2 Schauspieler die 10 Hauptrollen spielen?","rating":"2044"},
10-17 18:38:11.443: D/debug(13532): {"ident":"28685","ts":"20.12.2009 08:40","content":"<Frau> ich wohne jetzt hier fast 10 monate und habe heute endlich mal meinen nachbarn von nebenan kennengelernt[newline]<Alex> Glückwunsch [newline]<Frau> in der videothek... Hat sich 7 pornos ausgeliehen[newline]<Alex> lol","rating":"4787"},
10-17 18:38:11.443: D/debug(13532): {"ident":"12820�������������������������������������������������������������������������������������������������������������������������������������������������������������

```

\*I deleted most of the questionmarks to keep it clear.

```
@Override
    protected String doInBackground(String... params) {
        String urlStr = params[0];
        InputStream is = null;
        try {
            URL url = new URL(urlStr);
            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();
            connection.setReadTimeout(100 * 1000);
            connection.setConnectTimeout(100 * 1000);
            connection.setRequestMethod("GET");
            connection.setDoInput(true);
            connection.connect();
            int response = connection.getResponseCode();
            Log.d("debug", "The response is: " + response);
            is = connection.getInputStream();

            // read string
            // buffersize:
            // ~max 1024 - 5
            //
            SharedPreferences sharedPref = PreferenceManager
                    .getDefaultSharedPreferences(activity);
            String displayed_items = sharedPref.getString(
                    "pref_key_numberofitems", "10");
            int items = Integer.parseInt(displayed_items);

            if (items > 10) {
                final int bufferSize = 40960 * 2;
                byte[] buffer = new byte[40960 * 2];
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                while (true) {
                    int count = is.read(buffer, 0, bufferSize);
                    if (count == -1) {
                        break;
                    }

                    os.write(buffer);
                }
                os.close();

                result = new String(os.toByteArray(), "iso-8859-1");
                Log.d("debug", result);
            } else {
                final int bufferSize = 2048 * 7;
                byte[] buffer = new byte[2048 * 7];
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                while (true) {
                    int count = is.read(buffer, 0, bufferSize);
                    if (count == -1) {
                        break;
                    }

                    os.write(buffer);
                }
                os.close();

                result = new String(os.toByteArray(), "iso-8859-1");
                Log.d("debug", result);
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return result;

```

Edit: Is there another method to download data from an interface webiste? Maybe this would help me.