Thanks Paul you were correct.  I increased the buffer size by 8 times
and it worked.

On Mar 19, 10:28 pm, Paul Turchenko <paul.turche...@gmail.com> wrote:
> Try increasing your buffer size (or better, make it content-length-
> dependent). It seems that UI theread reseives too much tasks to do and
> this makes it other tasks to wait too long. This makes android show
> ANR message. If this not helps, try dealing with download from your
> own separate thread. This might help you find what's wrong. But IMHO,
> it seems that somethig else makes your UI thread starve - this causes
> ANR message.
>
> On Mar 20, 12:29 am, dsukhram <duanesukh...@gmail.com> wrote:
>
> > this is my inner class that handles the downloading and progressbar
>
> > public class DownloadDBTask extends AsyncTask<Object, Integer, Object>
> > {
> > private int mProgress;
>
> > public Object doInBackground(Object ...urls)
> > {
> > //download file
> > int totalSize =0;
>
> > try
> > {
> > URL urlFile = new URL("http://www.xxx.com/test.db";);
> > URLConnection conn;
> > conn = urlFile.openConnection();
> > totalSize = conn.getContentLength();
>
> > Log.i("INFO","total size of file "+totalSize);
> > BufferedInputStream bis = new
> > BufferedInputStream(urlFile.openStream());
> > BufferedOutputStream bout = new BufferedOutputStream(new
> > FileOutputStream(PATH+DB_NAME),1024);
> > byte data[] = new byte[1024];
> > int bufferSize =0;
> > int currentSize = 0;
>
> > while((bufferSize = bis.read(data)) != -1 )
> > {
>
> > currentSize +=bufferSize;
> > bout.write(data,0,bufferSize);
>
> > publishProgress((int) ((currentSize / (float) totalSize) * 100));
>
> > }
>
> > Log.i("INFO","Done downloading");
>
> > bout.flush();
> > bis.close();
> > bout.close();
>
> > }
>
> > catch(IOException e)
> > {
> > Log.e("ERROR",e.toString());
>
> > }
>
> > return (new Object());
>
> > }
>
> > public void onPostExecute(Object result) {
>
> > mProgressDialog.dismiss();
>
> > }
>
> > protected void onProgressUpdate(Integer... progress) {
>
> > mProgressDialog.setProgress(progress[0]);
>
> > }
>
> > protected void onPreExecute(){
>
> > showDialog(2);
>
> > }
> > }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to