android - Can't see the bitmap I saved to new directory -


I was looking for a way to save bitmap (with the name of my app) in a folder, like this The default gallery will recognize it from.

So I managed to save the image, but I can not see it with the gallery or my PC (using Explorer)

This is my code:

< Pre-save the bitmap to save the private bit in the internal // internal memory (bitmap BMP) {string appname = "mypad"; String file_path = environment GettyStyle StorePaulic Directory (Environmental. DIRECTORY_PICTURES) + file. Separator + appname; File directory = new file (file_path); If (! Dir.exists ()) dir.mkdirs (); // image file file file = new file (dir, "img" + "_" + system. Contenttime millilias () + ".jpg"); FileOutputStream Out = Null; {Out} Try new FileOutputStream (file); Bmp.compress (bitmap.compress format.jpeg, 100, out); Out.flush (); Out.close (); Out = null; } Hold (exception e) {e.printStackTrace (); }}

I can see it using some file manager installed on my galaxy, but it does not help much. I know that I should notify the gallery using a media scanner (which needs to cross a second bridge), but someone can help me understand that I do not even get the file. Will I change my visibility in some way?

And one more thing: I read on another issue about this issue, that I should add the metadata to the image / folder so that the gallery showed it to me. Is it necessary?

Many thanks!

Apparently there was something to do with the media scanner, I have added this line

  MediaScannerConnection.scanFile (this, new string [] {file.getAbsolutePath ()}, blank, zero);  

And now it works.

From the document:

MediaScannerConnection provides a method for creating or downloading a media file in the media scanner service. The media scanner reads the metadata from the service file and connects the file to the media content provider.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -