I'm using the following script based on the tutorial Android Series: Download files with Progress Dialog to download multiple video files from the internet to the SD card. It displays a progress bar while the download is in progress.
public class MyDownload extends Activity {
public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
private Button startBtn;
private ProgressDialog mProgressDialog;
private String videoPath = "http://my_site.com/test_videos/";
private String[] fileNames = {"file1.mp4","file2.mp4"};
private TextView tv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startBtn = (Button)findViewById(R.id.startBtn);
startBtn.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
startDownload();
}
});
}
private void startDownload() {
tv = (TextView) findViewById(R.id.TextView01);
if(checkExternalMedia()==true) {
File file = null;
for(int i=0; i
}
This code works fine when the size of each video is less (around 300KB). But when the video size increases to 7-8 MB the application crashes.
However, if I try to download a single large file instead of
private String[] fileNames = {"file1.mp4","file2.mp4"};
this code works fine. Any thoughts ?