0

my code is given below . i want to type URI in the edittext and download that file by clicking the download button.so please give me a solution for downloading the file.

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/txtvUri"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/URi"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <EditText
            android:id="@+id/etxtUri"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" 
            android:hint="Enter the URI">

            <requestFocus />
        </EditText>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/download"
            android:clickable="true"
            android:onClick="click" />

    </LinearLayout>

</LinearLayout>
Ajay Raj
  • 1
  • 1
  • Possible duplicate http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog – cjds Dec 20 '12 at 04:23

1 Answers1

1

You can use Apache HttpClient or java's HttpURLConnection.

Check out http://www.androidsnippets.com/download-an-http-file-to-sdcard-with-progress-notification for an example of the latter.

Scott Stanchfield
  • 29,742
  • 9
  • 47
  • 65