Public voidStorepic (StringTabIDStringKeyBitmapBitmap) {
logutils.LOGD(TAG,"Storepic Begin tabid ="+ TabID +"key ="+ key);
FileOutputStreamFOS =NULL;
Try{
FOS = Getactivity (). Openfileoutput (TabID +"_" + Key, Context.mode_private);
Bitmap.compress (Bitmap.compressformat.PNG, -, FOS);
}Catch(FileNotFoundExceptionE) {
logutils.LOGE(TAG,"Storepic filenotfoundexception e ="+E);
}finally{
if(Fos! =NULL) {
Try{
Fos.flush ();
Fos.close ();
}Catch(IOExceptionE) {
logutils.LOGE(TAG,"Storepic ioexception e ="+E);
}
}
}
}
PublicBitmapGetstorepic (StringTabIDStringKey) {
logutils.LOGD(TAG,"Getstorepic Begin tabid ="+ TabID +"key ="+ key);
FileInputStreamFin =NULL;
BitmapBitmap =NULL;
Try{
Fin = getactivity (). Openfileinput (TabID +"_" + key);
Bitmap =bitmapfactory.Decodestream(Fin);
}Catch(FileNotFoundExceptionE) {
logutils.LOGE(TAG,"Getstorepic filenotfoundexception e ="+ e);
}
returnBitmap
}
Total and process:
Store Picture code:[Java]View PlainCopy
- String str1 = "Icon.png" ;
-   
- fileoutputstream localfileoutputstream1 = openfileoutput (str1, < Span style= "margin:0px; padding:0px; Border:none; Color: #c00000; Background-color:inherit ">0
- Bitmap.compressformat Localcompressformat = Bitmap.CompressFormat.PNG;
- &NBSP;&NBSP;
- bitmap.compress (Localcompressformat, 100 , localfileoutputstream1 );
- Localfileoutputstream1.close ();
To read the image code:
[Java]View PlainCopy
- string localiconnormal = " icon.png " ;&NBSP;&NBSP;
- FileInputStream Localstream = Openfileinput (localiconnormal);
- Bitmap Bitmap = Bitmapfactory.decodestream (Localstream));
Android stores pictures to the data directory and reads pictures under the data directory