Reputation: 21
I've created a file in the SD card using the code below:
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 this file browsing SD card contents through Windows Explorer in my computer (phone connected via USB), all SD card folders and files are displayed, except mine. Astro displays the file, but not as a thumbnail.
Strangest thing is that this happens only with one of my phones (a Samsung Galaxy X phone), and if I reboot this phone, file is displayed both within Windows Explorer and as a thumbnail in Astro.
Could there be something wrong or missing in the code I wrote?
Thanks
Upvotes: 2
Views: 2185
Reputation: 111
Maybe there is some Windows caching behind in order not to continuously poll the directory listing. Try hitting F5 in Explorer to see if file comes up. In any case, file should be visible in Eclipse's phone File Explorer (in DDMS Perspective).
Upvotes: 0
Reputation: 3744
image files need to be explicitly indexed in order to appear in the gallery. I suppose other applications may be using the same mechanism to get the thumbnail. Here is some code that will scan a new media file, right after you wrote it:
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri uri = Uri.fromFile(outputFile);
intent.setData(uri);
sendBroadcast(intent);
Upvotes: 1