SD card SD file not showing

I created the file on the SD card using the following code:

File outputFile = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "test.jpg" ); outputFile.createNewFile(); OutputStream outputStream = new FileOutputStream( outputFile ); mBitmap.compress( Bitmap.CompressFormat.JPEG, 95, outputStream ); outputStream.flush(); outputStream.close (); 

When I try to see how this file views the contents of the SD card through the Windows Explorer on my computer (the phone is connected via USB), all folders and files of the SD cards except my mine are displayed. Astro displays the file, but not as a thumbnail.

The strangest thing is that this happens only with one of my phones (Samsung Galaxy X phone), and if I restart this phone, the file is displayed both in Windows Explorer and as a thumbnail in Astro.

Could there be something wrong or not in the code that I wrote?

thanks

+2
source share
2 answers

image files must be explicitly indexed for display in the gallery. I believe that other applications can use the same mechanism to get thumbnails. Here is the code that scans the new media file immediately after writing it:

  Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(outputFile); intent.setData(uri); sendBroadcast(intent); 
+1
source

There may be some caching of Windows, so as not to constantly poll the list of directories. Try pressing F5 in Explorer to see if the file appears. In any case, the file should be visible in Eclipse Phone Explorer (in DDMS Perspective).

0
source

All Articles