1

Please tell me how set saving path for downloading file.

For example:

AsyncHttpClient client = new AsyncHttpClient();
String[] allowedTypes = new String[] { "image/png" };
client.get("http://www.example.com/image.png", new BinaryHttpResponseHandler(allowedTypes) {
    @Override
    public void onSuccess(byte[] imageData) {
        // Successfully got a response
    }

    @Override
    public void onFailure(Throwable e, byte[] imageData) {
        // Response failed :(
    }
 });
morten.c
  • 3,414
  • 5
  • 40
  • 45
Kozlov V
  • 146
  • 5
  • 17
  • 1
    Very Short Explanation. Try to be brief about issue – Aamirkhan Dec 04 '13 at 11:25
  • This the question of the use of lib loopj. In particular, how to set a path for the file to be loaded. Mr. Aamirkhan I'm sorry if the question is not clear why put a minus – Kozlov V Dec 04 '13 at 11:38

1 Answers1

3

You need use this byte array with an OutputStream subclass to write the bytes on disc,

OutputStream f = new FileOutputStream(new File("path"));
f.write(bytes); //your bytes
f.close();

This code will write the file on disk, to get the path maintain the File on a variable and use File.getAbsolutePath()

Leonardo
  • 155
  • 3