سلام
خسته نباشید
نقش URLconnection در این کد چیست؟ در صورتی که نباشه باز کار میکنه. پس برای چیه
من یک فایل صوتی را از اینترنت به کارت حافظه ی گوشی کپی میکنم
public void buttonClickListener(View v) {
tt.start();
}
private Thread tt=new Thread()
{
@Override
public void run() {
super.run();
try {
URL url=new URL("http://s8.picofile.com/d/8349389850/06c69ac4-70fb-4d33-991f-ac01b8c5324f/b.mp3");
//URLConnection connection=url.openConnection();
//connection.connect();
InputStream fis=url.openStream();
FileOutputStream fos=new FileOutputStream(Environment.getExternalStorageDir ectory().getPath()+"/d.mp3");
int c;
while ((c=fis.read())!=-1)
{
fos.write(c);
}
fos.flush();
fos.close();
fis.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
};