title: Populate secondActivity listview from mainActivty
body: <p>I would like to populate listview in secondActivity with url when data from url is downloaded i tried diffrent stuff but nothing works</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>    public class MainActivity extends ActionBarActivity {
  
  private static final String DEBUG_TAG = "HttpExample";
  private EditText urlText;
  private TextView textView;
  SharedPreferences.Editor fd;
  SharedPreferences FeedPref;
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      urlText = (EditText) findViewById(R.id.myurl);
      textView = (TextView) findViewById(R.id.mytext);
      textView.setMovementMethod(ScrollingMovementMethod.getInstance());
      FeedPref=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
      fd=FeedPref.edit(); 
  
  
  
  }
  
  
  public void  myClickHandler(View view) {
  
  
  
  
      // Gets the URL from the UI's text field.
      String stringUrl = urlText.getText().toString();
      ConnectivityManager connMgr = (ConnectivityManager) 
          getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
      if (networkInfo != null &amp;&amp; networkInfo.isConnected()) {
  
  
          new DownloadWebpageTask().execute(stringUrl);
  
      } else {
          textView.setText("No network connection available.");
      }
  }
  
  
  
   public class DownloadWebpageTask extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected String doInBackground(String... urls) {
  
  
  
              // params comes from the execute() call: params[0] is the url.
              try {
                  return downloadUrl(urls[0]);
              } catch (IOException e) {
                  return "Unable to retrieve web page. URL may be invalid.";
              }
          }
  
  
         // onPostExecute displays the results of the AsyncTask.
          @Override
          protected void onPostExecute(String result) {
              textView.setText(result);   
              if (result != null  )
              {
             FeedPref=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
             fd=FeedPref.edit();
           String url =urlText.getText().toString(); 
           fd.putString("urls", url);
           fd.commit(); }
  
  
  
         }
      }
  
   private String downloadUrl(String myurl) throws IOException {
          InputStream is = null;
  
  
          try {
              URL url = new URL(myurl);
              HttpURLConnection connect = (HttpURLConnection) url.openConnection();
              connect.setReadTimeout(10000 /* milliseconds */);
              connect.setConnectTimeout(15000 /* milliseconds */);
              connect.setRequestMethod("GET");
              connect.setDoInput(true);
              // Starts the query
              connect.connect();
              int response = connect.getResponseCode();
              Log.d(DEBUG_TAG, "The response is: " + response);
              is = connect.getInputStream();
  
              // Convert the InputStream into a string
              String contentAsString = readIt(is);
              return contentAsString;
  
          // Makes sure that the InputStream is closed after the app is
          // finished using it.
          } finally {
              if (is != null) {
                  is.close();
              } 
          }
   }
  
  // Reads an InputStream and converts it to a String.
   public String readIt(InputStream stream) throws IOException, UnsupportedEncodingException {
       if (stream != null) {
           StringBuilder sb = new StringBuilder();
           String line;
  
           try {
               BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
               while ((line = reader.readLine()) != null) {
                   sb.append(line);
               }
           } finally {
               stream.close();
           }
           return sb.toString();
       } else {        
           return "";
       }
   }
   public void myClickHandler1(View povijest){
       Intent intent = new Intent(MainActivity.this, SecondActivity.class);
       startActivity(intent);      
  
   }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>secondactivity.java</strong></p>
  
  <pre><code>package com.example.networking;
  
  import java.util.ArrayList;
  
  import android.support.v7.app.ActionBarActivity;
  import android.content.Context;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.preference.PreferenceManager;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.TextView;
  
  public class SecondActivity extends ActionBarActivity {
          String[] urls1;
          ListView listView;
          ArrayAdapter&lt;String&gt; adapter;
          SharedPreferences FeedPref;
          SharedPreferences.Editor fd;
          TextView txt1;
  
  
  
      protected void onCreate(Bundle savedInstanceState) {
          FeedPref=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
          String  urlsa=FeedPref.getString("urls",null);
            String[] values = new String[] {urlsa,};
            ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, android.R.id.text1, values);
  
  
  
  listView.setAdapter(adapter);
  
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.second, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
          if (id == R.id.action_settings) {
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/LinearLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.networking.MainActivity" &gt;
  
      &lt;EditText
          android:id="@+id/myurl"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
           android:inputType="textWebEmailAddress"
          android:ems="10" &gt;
  
      &lt;/EditText&gt;
  
      &lt;TextView
          android:id="@+id/mytext"
          android:layout_width="200dp"
          android:layout_height="0dp"
          android:layout_marginLeft="38dp"
          android:layout_marginTop="40dp"
          android:layout_weight="0.17"
          android:scrollbars="vertical" /&gt;
  
      &lt;Button
          android:id="@+id/button2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="start"
          android:onClick="myClickHandler1"
          android:text="POVIJEST" /&gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:onClick="myClickHandler"
          android:text="Download" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>activity_second.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.networking.SecondActivity" &gt;
  
      &lt;ListView
          android:id="@+id/lista"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true" &gt;
      &lt;/ListView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Edit</strong>
  I tried to use sharedPrefrences with onPostExecute but i does not work.
  So i would like every ulr that gets downloaded to be saved to listview.</p>