1. Android Central Question's Avatar
    I have look all (not all but as far as i could) over sites and most likely the stack-overflow, there are lot of answers, and none seem to be working in my case... i also tried to pass Uri to the file.

    so user previously select a folder, i read all files from that folder, then user choose a directory, and i want to store those file with some modifications on there :|
    I use Intent.createChooser

    the furthest i got i case of debuging... is here:

    public void saveImage(Bitmap bmp, Uri uri, String filename){
    FileOutputStream out = null;
    try {
    String uriString = "file" + uri.toString().substring(uri.toString().indexOf(':'))+ FILE_PATH_SEPARATOR_ESCAPE +filename;
    String path = (uri.getPath()+"/"+filename).replace("_", UNDERSCORE_ESCAPE).replace(" ", SPACE_ESCAPE);
    URI fileUri = new URI(path);
    //File f = new File(fileUri);

    out = new FileOutputStream(fileUri);
    bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance
    // PNG is a lossless format, the compression factor (100) is ignored
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    try {
    if (out != null) {
    out.close();
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    I/Test: Result URI content://com.android.externalstorage.documents/tree/2085-19F5%3AHassan%2FGo%20Mob%2057%2F28
    W/System.err: java.lang.IllegalArgumentException: URI is not absolute: /tree/2085-19F5:Hassan/Go%20Mob%2057/28/DSC%5F0226.jpg
    W/System.err: at java.io.File.checkURI(File.java:220)
    W/System.err: at java.io.File.<init>(File.java:177)
    W/System.err: at ir.faqihi.hassan.buckwatermark.MainActivity.saveImage(MainActivity.java:242)
    W/System.err: at ir.faqihi.hassan.buckwatermark.MainActivity.generateWatermarkedImageOutput(MainActivity.java:225)
    W/System.err: at ir.faqihi.hassan.buckwatermark.MainActivity.onActivityResult(MainActivity.java:185)
    W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:6192)
    W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:3676)
    W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:3723)
    W/System.err: at android.app.ActivityThread.access$1300(ActivityThread.java:156)
    W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400)
    W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
    W/System.err: at android.os.Looper.loop(Looper.java:211)
    W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5389)
    W/System.err: at java.lang.reflect.Method.invoke(Native Method)
    W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
    W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
    W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
    Disconnected from the target VM, address: 'localhost:8628', transport: 'socket'
    05-26-2018 01:51 PM

Similar Threads

  1. Pixel 2 wifi hotspot is invisible to the world!!!
    By The.Walrus in forum Google Pixel 2 & Pixel 2 XL
    Replies: 13
    Last Post: 05-31-2018, 08:00 PM
  2. How to enable gps on my ui5001f
    By Android Central Question in forum Ask a Question
    Replies: 1
    Last Post: 05-26-2018, 05:27 PM
  3. Replies: 1
    Last Post: 05-26-2018, 05:24 PM
  4. Is there a way to calibrate the galaxy s5?
    By Android Central Question in forum Ask a Question
    Replies: 1
    Last Post: 05-26-2018, 02:31 PM
  5. how do i connect link from dropbox to my gmail?
    By Android Central Question in forum Ask a Question
    Replies: 1
    Last Post: 05-26-2018, 12:49 PM
LINK TO POST COPIED TO CLIPBOARD