0

I'm writing an image to the external storage directory using an android app, but it is not being refreshed. I have looked at some other people's problems ( eg 1, 2 and 3 ) and I can't solve my problem; basically, the folder doesn't get refreshed until I come out out and close down my "folder view". Starting it up again refreshes the view and shows the newly placed images.

Here's my code:

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = Environment.getExternalStorageDirectory()+ "/" + timeStamp + "_original.jpg";

   OutputStream fout = null;
    File imageFile = new File(imageFileName);

    try {
        fout = new FileOutputStream(imageFile);
        croppedbitmap.compress(Bitmap.CompressFormat.JPEG, 95, fout);
        fout.flush();
        fout.close();
        //Toast.makeText(this, "Success", Toast.LENGTH_LONG).show();

    } catch (Exception e) {


    }

   MediaScannerConnection.scanFile(this, imageFileName, null,
            new MediaScannerConnection.OnScanCompletedListener() {
                public void onScanCompleted(String path, Uri uri) 
                {

                }
            });

I'm guessing that its something to do with a mismatch between the filename and the path, but I am not familiar with the use of the mediascanner on android. Can someone please help? Thanks.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
user3713442
  • 478
  • 8
  • 22

0 Answers0