How to be sure that files are saved in gallery for all Android devices? <p>According to user reviews, my app dosn't save on their phones (LG4, oneplus phones, android 5.1, Android 6.0)</p> <p>For Android 6.0 I have solved the problem by using the new permission system. But how can I be sure that the code actually works 100% on all devices? Is there any improvment that can be made?</p> <p><strong>This is the onClick method that is run, when the user clicks the save button But also ask for permission for Android 6 devices</strong></p> <pre><code>public void saveQuote(View v) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { //check if we have permissoin to WRITE_EXTERNAL_STORAGE if (PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { //This method just create a bitmap of my edittext saveBitmap(); } else { //if permission is not granted, then we ask for it ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_EXTERNAL_STORAGE); } } } </code></pre> <p><strong>This is the code that makes the saving operation:</strong></p> <pre><code>private void saveImageToExternalStorage(Bitmap finalBitmap) { String filename = "#" + pref_fileID.getInt(SAVE_ID, 0) + " Quote.JPEG"; //The directory in the gallery where the bitmaps are saved File myDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + "/QuoteCreator"); //The directory in the gallery where the bitmaps are saved File myDir = new File(root + "/QuoteCreator"); //creates the directory myDir. myDir.mkdirs(); File file = new File(myDir, filename); try { FileOutputStream out = new FileOutputStream(file); finalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); Toast.makeText(getApplicationContext(), R.string.savedToast, Toast.LENGTH_LONG).show(); } catch (Exception e) { e.printStackTrace(); } /* Tell the media scanner about the new file so that it is immediately available to the user. */ MediaScannerConnection.scanFile(this, new String[]{file.toString()}, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.i("ExternalStorage", "Scanned " + path + ":"); Log.i("ExternalStorage", "-&gt; uri=" + uri); } }); } </code></pre>