title: Save file to internal storage and show in gallery
body: <p>I should save an image (byte []) inside the internal memory and make it visible inside the gallery, but the following code does not work, what's wrong? the file is not saved and shown in the gallery but no error is generated</p>
  
  <pre><code>private void saveImageToDisk(final byte[] bytes) {
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-hh:mm");
      String todayDate = dateFormat.format(new Date());
      Log.d("Foto data: ",todayDate);
      File file = new File(context.getFilesDir(), "image.jpg");
      try (final OutputStream output = new FileOutputStream(file)) {
          output.write(bytes);
          output.close();
  
      } catch (final IOException e) {
          Log.e("TAG", "Exception occurred while saving picture to storage ", e);
      }
  
  
  
      Log.d("Foto","File salvato"+ file.getAbsolutePath());
      addPicToGallery(file.getPath());
  
  }
  
  private void addPicToGallery(String photoPath) {
      Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
      File file = new File(photoPath);
      Uri contentUri = Uri.fromFile(file);
      mediaScanIntent.setData(contentUri);
      this.sendBroadcast(mediaScanIntent);
  }
  </code></pre>