download an image from the webserver to sd card

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

download an image from the webserver to sd card

Postby arungupta2jan » Mon Oct 05, 2009 9:45 am

hi all ,
i am trying to download an image from the webserver to sd card of my device the downloading is happening but i am unable to see the image..
plz have a look on them code

code

FileWriter filewriter = new FileWriter("/sdcard/arun.gif");

Log.i("file status", "file created");

URL rurl = new URL("http://www.vaderradar.se/create_images.php?height=400&width=400&id=0");

URLConnection con= rurl.openConnection();

con.connect();

is=con.getInputStream();
// creating a file and opening a connection to the web server

while((b=is.read())!=-1)

{
filewriter.write((char)b);
}

//writting to the file

Log.i("writing"," done");

is.close();

filewriter.close();
// closing the file and webconnection



plz tell me what is wrong here


regards
Arun gupta
arungupta2jan
Developer
Developer
 
Posts: 28
Joined: Tue Jul 28, 2009 12:53 pm

Top

Postby Sowmya » Mon Oct 05, 2009 1:48 pm

Filewriter is for character streams..Since your are saving a image you should use FileOutputStream...
Sowmya
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Mar 06, 2009 7:49 am

Postby arungupta2jan » Mon Oct 05, 2009 1:56 pm

that is why when i was trying to write a text file it was easily written and displayed thanks for the answer
arungupta2jan
Developer
Developer
 
Posts: 28
Joined: Tue Jul 28, 2009 12:53 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests