Download Files By Using AQuery Library

1k Views Asked by At

I Am Ussuing AQuery And Tring To Use This Library To Dowbload Files but i dont understand how to use it.

Thats Sample Code , But I Don't Understand It.

aq.download(String url, File target, Object handler, String callback)

How To Derfine "Object handler" and "String callback" ?

1

There are 1 best solutions below

0
On

You can try this way

        File ext = Environment.getExternalStorageDirectory();
        File target = new File(ext, "image/test.jpg");              

        aq.download(imageURL, target, new AjaxCallback<File>(){
            public void callback(String url, File file, AjaxStatus status) {
                if(file != null){
                    Toast.makeText(getApplicationContext(), "File:" + file.length() + ":" +file+"-"+status, 
                            Toast.LENGTH_LONG).show();
                }else{
                    Toast.makeText(getApplicationContext(), "Download Failed", Toast.LENGTH_LONG).show();
                }
            }

        });