---
title: "How to download string from webpage in android"  
description: "How to download string from webpage in android"  
author: "Norman Reedus"  
published: 2014-11-07  
updated: 2014-11-07  
canonical: https://www.mindstick.com/forum/2541/how-to-download-string-from-webpage-in-android  
category: "android"  
tags: ["java"]  
reading_time: 2 minutes  

---

# How to download string from webpage in android

I am making an app that will [download](https://www.mindstick.com/articles/188403/website-to-download-photos-from-instagram) a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) from a [website](https://www.mindstick.com/articles/13110/why-copywriting-is-crucial-for-new-website-build) and display it. I tried many examples [online](https://www.mindstick.com/articles/13083/benefits-of-students-who-can-get-online-assignment) and I've literally been searching for [days](https://www.mindstick.com/articles/157271/how-to-get-cloudways-free-trial-for-14-days-free) for this, but I can't find a single solution.

From what I have read, I know I have to get the [content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand) of the [url](https://www.mindstick.com/forum/436/url-redirection) from another thread, but no tutorial showed me how to do this.

I have a [textview](https://www.mindstick.com/forum/23237/how-do-i-center-text-horizontally-and-vertically-in-a-textview-in-android) on the [layout](https://www.mindstick.com/articles/12853/android-layout-and-its-type) and that will be where the [html](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) content will have to show up.

Can anybody show me an example of how this is done?

## Replies

### Reply by Anonymous User

What about something like this?

```
public class MyAsyncTask extends AsyncTask<String, Void, String>
{
    @Override
    protected String doInBackground(String... requestUrl)
    {
        String result = null;

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpGet request = new HttpGet(requestUrl[0]);

        try
        {
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            result = httpClient.execute(request, responseHandler);
        }
        catch (IOException e)
        {
            Log.e("requestStringFromWebServer", "Whoops!", e);
        }

        httpClient.getConnectionManager().shutdown();

        return result;
    }

    @Override
    protected void onPostExecute(String result)
    {
        if (result != null)
        {
            // Handle the result from your request here...
        }
    }
}
```

And kick it off with

```
String myUrlStr; // Initialize this to your url
new MyAsyncTask().execute(myUrlStr);
```


---

Original Source: https://www.mindstick.com/forum/2541/how-to-download-string-from-webpage-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
