使用xutils下载服务器文件文件

public class MainActivity extends Activity {


private EditText ed_path;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed_path = (EditText) findViewById(R.id.ed_path);
}

String path;
public void download(View v){

path = ed_path.getText().toString().trim();

HttpUtils utils = new HttpUtils();
utils.download(path, "/mnt/sdcard/123.txt", true, new RequestCallBack(){


@Override
public void onStart() {
super.onStart();
System.out.println("开始下载了 ");
}

@Override
public void onLoading(long total, long current, boolean isUploading) {
super.onLoading(total, current, isUploading);

System.out.println("正在 下载中  ");
}

@Override
public void onSuccess(ResponseInfo responseInfo) {

System.out.println("下载成功");
}


@Override
public void onFailure(HttpException error, String msg) {

System.out.println("下载失败");
}


});

}

}

你可能感兴趣的:(android,基础)