Q:

Generated QR image disappers once i exit the application

Recently am being playing around with qr code generation, and after alot of google and help from stack overflow members i was successfully able to generated it, using google API.
but when i click "back" button in the emulator and when i again click theapplication the qr code image disappears??
how to make it stay permanent until i click the "generate" button again for a new Qr image??
here is the code for my question's answer providers and those who are struggling in generation of qr images 
    package com.test2;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class Test2Activity extends Activity {

     ImageView QRCode;
     TextView MySite;
     EditText text,text1; 
     Button genarate;
     String textbox,textbox2;

       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);

           QRCode = (ImageView)findViewById(R.id.qrimage);
           MySite = (TextView)findViewById(R.id.mysite);

           genarate=(Button)findViewById(R.id.genarate);
           genarate.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                text=(EditText)findViewById(R.id.text);
                text1=(EditText)findViewById(R.id.text1);
                textbox=text.getText().toString();
                textbox2=text1.getText().toString();
                Bitmap bm = loadQRCode();
                    if(bm == null){
                    Toast.makeText(Test2Activity.this,
                      "Problem in loading QR Code1",
                      Toast.LENGTH_LONG).show();
                   }else{
                    QRCode.setImageBitmap(bm);
                   }
            }
                    Bitmap loadQRCode(){
                    Bitmap bmQR = null;
                    InputStream inputStream = null;

                    try {
                   inputStream = OpenHttpConnection("http://chart.apis.google.com/chart?chs=400x400&cht=qr&chl="+ textbox +"--->"+ textbox2);
                   bmQR = BitmapFactory.decodeStream(inputStream);
                   inputStream.close();
                  } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
                  }
                    return bmQR;
                   }

                   private InputStream OpenHttpConnection(String strURL) throws IOException{
                    InputStream is = null;
                    URL url = new URL(strURL);
                    URLConnection urlConnection = url.openConnection();

                    try{
                     HttpURLConnection httpConn = (HttpURLConnection)urlConnection;
                     httpConn.setRequestMethod("GET");
                     httpConn.connect();

                     if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                      is = httpConn.getInputStream(); 
                     }
                     }catch (Exception ex){
                     }

                    return is; 
                 }  
        });
       }
    }

xml code for this activity
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >
<TextView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="@string/hello"
   />

<EditText
    android:id="@+id/text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

<EditText
    android:id="@+id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <requestFocus />
</EditText>

<Button
    android:id="@+id/genarate"
    android:layout_width="97dp"
    android:layout_height="wrap_content"
    android:text="genarate" />

<ImageView 
   android:id="@+id/qrimage"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:saveEnabled="true" android:visibility="visible"/>

<TextView 
   android:id="@+id/mysite"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   />
</LinearLayout>

    </ScrollView>

A:

You can save the generated image as a Base64 string in your SharedPreferences.
To encode the image do something like: Base64.encode(image, Base64.DEFAULT).
To store and retrieve values from your SharedPreferences you can use in your Activity:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);   

//Save String
preferences.edit().putString("image64", imageData).commit();

//Get String
String imageBase64 = preferences.getString("image64", null);
                                                       ^----- Default value
if(imageBase64 == null)
    Log.d("LOG", "No image stored in the SharedPreferences");

//Create a bitmap from the base64 data
byte[] decodedString = Base64.decode(imageBase64, Base64.DEFAULT);
Bitmap bm = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);

