Android save gif from database to file -


In my app's database I have stored a GIF image as Blob. I will remove this GIF from the database. Can I save it as a GDP file in SDCD? For PGG and JPEG I know how to do this. How can I get this without any library? I like this code for PGG and JPEG:

  bytereinputstream imagestream; ImageStream = New Bytereinputstream (ImageBlob); Bitmap image = bitmapfichtor. Decodestream (imagestream); StoreImage (image); Private Zero Collection Image (Bitmap Image) {File File File = getOutputMediaFile (); If (picturefile == empty) {return; } {FileOutputStream fos = try New FileOutputStream (pictureFile); Image.compress (bitmap.compress format.png, 90, font); Fos.close (); } Hold (FileNotFoundException e) {Log.i ("MyApp", "File not found:" + e.getMessage ()); } Hold (IOException e) {Log.i ("MyApp", "Error accessing file:" + e.getMessage ()); }} // To get the path for image storage, get the personal file getOutputMediaFile (file {file mediastorage.dew = new file (EnvironmentalGetEnsteinTorories directory) "" / Android / data / "+ contexto.getPackageName () +" / files " ); // Create Storage Directory If it does not exist, then (! MediaStorageDir.exists ()) {if (! MediaStorageDir.mkdirs ()) {return null; }} // Create a media file name file mediaFile; String mImageName = "myImage.png"; MediaFile = new file (mediaStorageDir.getPath () + file. Separator + mImageName); Return media file; }  

I tried down without success This file does not make it. I do not know what is wrong or if I'm missing something.

  bytereinputstream imagestream = new bytereinputstream (image blob); Bytereon OutputStream Bytebuff = New BytereOutStream (); Int buffer size = 1024; Byte [] buffer = new byte [buffer size]; Int len ​​= 0; While ((len = imageStream.read (buffer))! = -1) {byteBuffer.write (buffer, 0, lane); } FileOutputStream Stream = New FileOutputStream (myPath); Stream.write (byteBuffer.toByteArray ());  

Please help in advance thanks in advance.

  bytereinputstream image stream = new bytereinputstream (image blob);  

Once you can save only that file in the stream, do not create a bitmap about it and do not use a bitmapfactory. You can use it for PNG, JPG and GIF.


Comments