Disable back button in Android(Not working)
<pre><code>package com.my.app ;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Comparator;

import com.my.app .R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.CompressFormat;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Base64;
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;

public class ImageInfo extends Activity {

    private static final int CAMERA_PIC_REQUEST = 1111;
    private ImageView mImage;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mImage = (ImageView) findViewById(R.id.camera_image);
        //1
        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, CAMERA_PIC_REQUEST);
    }



    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(resultCode != RESULT_CANCELED)   {
            if(requestCode == CAMERA_PIC_REQUEST){

                Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
                //  mImage.setImageBitmap(thumbnail);
                //3
                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
                //4
                File file = new File("data/data/com.my.app /photo.jpg");
                File myDir=new File("data/data/com.my.app /");
                try {
                    String encodedPhotoImage;

                    file.createNewFile();
                    FileOutputStream fo = new FileOutputStream(file);
                    //5
                    fo.write(bytes.toByteArray());
                    fo.close();
                    deleteLatest() ;


                    byte[] photoImgBytes=readPhotoFile();
                    ByteArrayOutputStream bao1 = new ByteArrayOutputStream();

                    Bitmap bitmapPhoto = BitmapFactory.decodeByteArray(photoImgBytes, 0, photoImgBytes.length);
                    bitmapPhoto.compress(Bitmap.CompressFormat.JPEG, 100,bao1);
                    byte[] by = bao1.toByteArray();

                    String by1 = Base64.encodeToString(by, 0);
                    encodedPhotoImage =  URLEncoder.encode(by1);
                    file.delete();

                    if (!myDir.exists()) {
                        myDir.mkdirs();
                    }
                    File encryptedFile=new File("data/data/com.my.app /photo.txt");
                    encryptedFile.createNewFile();
                    FileWriter writer = new FileWriter(encryptedFile);
                    writer.append(encodedPhotoImage);
                    writer.close();
                    //Base64.encodeToString(ba1, Base64.DEFAULT);
                    Intent intent=new Intent(ImageInfo.this,Info.class);
                    startActivity(intent);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
        }
    }

    private byte[] readPhotoFile(){         
        String url="data/data/com.my.app /photo.jpg";
        Log.e("","Image is"+url);
        Bitmap bm = BitmapFactory.decodeFile(url);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();  
        bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        byte[] b = baos.toByteArray(); 
        return b;
    }

    @Override
    public void onBackPressed() {
        // do nothing.
    }


    private void deleteLatest() {
        File f = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera" );
        File [] files = f.listFiles();
        Arrays.sort( files, new Comparator&lt;Object&gt;()
                {
            public int compare(Object o1, Object o2) {
                if (((File)o1).lastModified() &gt; ((File)o2).lastModified()) {
                    return -1;
                } else if (((File)o1).lastModified() &lt; ((File)o2).lastModified()) {
                    return 1;
                } else {
                    return 0;
                }
            }

                });
        files[0].delete();
    }
}
</code></pre>

<p>This is my java file. I have already disabled the back button using </p>

<pre><code>public void onBackPressed() {
        // do nothing.
    }
</code></pre>

<p>But when back button is pressed in the app, the entire screen becomes black. Please find screen shot <img src="http://i.stack.imgur.com/Hemsp.png" alt="enter image description here">. The app hangs and the only way it can be accessed by terminating it through task manager and then restarting it. </p>
