how to add progressbar inside alert dailog?
<p>how do i add progess bar when user select "yes" button  inside alert dailog plz help me how do i do this??  when user enter password in this line alert.setMessage("Please Enter A Password For Files"); how do i start progress bar which show progress status??</p>

<pre><code> public class EasyFileEncrypt extends Activity {

private static final AlgorithmParameterSpec AES_Key_Size = null;
ProgressDialog progressBar;
private int progressBarStatus = 0;
private Handler progressBarHandler = new Handler();

private long fileSize = 0;



String filePath = "";
String password = "";
int SELECT_MULTI_FILE = 1;

static long fileSizeInBytes = 0;
private Context magicContext;
public Vector magicNamesVector;
public Boolean lastEncrypt = false;


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




    Button meButton = (Button) findViewById(R.id.multiencryptbutton);
    meButton.setOnClickListener(new OnClickListener() {



        public void onClick(View v) {
            magicNamesVector.clear();
            lastEncrypt = true;
            magicNamesVector.clear();
            magicContext = v.getContext();

            Intent intent = new Intent(v.getContext(),  
    FileDialog.class);
            intent.putExtra(FileDialog.START_PATH, "/sdcard");
            startActivityForResult(intent, SELECT_MULTI_FILE);
        }
    });


    Button mdButton = (Button) findViewById(R.id.multidecryptbutton);
    mdButton.setOnClickListener(new OnClickListener() {


        public void onClick(View v) {
            magicNamesVector.clear();
            lastEncrypt = false;
            magicNamesVector.clear();
            magicContext = v.getContext();

            Intent intent = new Intent(v.getContext(),  
   FileDialog.class);
            intent.putExtra(FileDialog.START_PATH, "/sdcard");
            startActivityForResult(intent, SELECT_MULTI_FILE);
        }
    });





}


public void scrambleFile(Boolean descramble) {

    // get a handle to the name
    // read in .old file
    // write out file
    // delete .old file?

    // rename file to .old
    String fileString = filePath;
    File oldfile = new File(fileString);
    File newfile = new File(fileString + ".old");
    oldfile.renameTo(newfile);


    // now try to open the first output file


    if (descramble == true) {

        SimpleCrypto crypto = new SimpleCrypto();
        try {
            Boolean madeit =  
 crypto.decryptFile(newfile,oldfile,password);
        } catch (InvalidKeyException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        newfile.delete();
        Toast.makeText(getBaseContext(), "Decrypted " + fileString,
                Toast.LENGTH_SHORT).show();
    } else {
        SimpleCrypto crypto  = new SimpleCrypto();
        try {
            Boolean madeit =  
  crypto.encryptFile(newfile,oldfile,password);
        } catch (InvalidKeyException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        newfile.delete();
        Toast.makeText(getBaseContext(), "Encrypted " + fileString,
                Toast.LENGTH_SHORT).show();
    }

}

/*public String getFileName() {
    int slashloc = filePath.lastIndexOf("/");
    if (slashloc &lt; 0) {
        return filePath;
    } else {
        return filePath.substring(slashloc + 1);
    }
}
 */
public void onActivityResult(final int requestCode, int resultCode,
        final Intent data) {
    if (resultCode == RESULT_OK) {

        if(requestCode == SELECT_MULTI_FILE) {
            filePath = data.getStringExtra(FileDialog.RESULT_PATH);
            askForAnother(filePath);

        }
    } else if (resultCode == RESULT_CANCELED) {
    }
}

public void askForAnother(String newPath) {
    magicNamesVector.add(newPath);

    AlertDialog.Builder alert = new AlertDialog.Builder(magicContext);
    alert.setTitle("Add Another?");
    alert.setMessage("You Just Added " + newPath + ", which makes "
            + magicNamesVector.size() + " items, add another?");

    // Set an EditText view to get user input
    // final EditText input = new EditText(context);
    // input.setInputType(InputType.TYPE_CLASS_NUMBER);
    // input.setText("1");
    // alert.setView(input);

    alert.setPositiveButton("YES", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            Intent intent = new Intent(magicContext, FileDialog.class);
            intent.putExtra(FileDialog.START_PATH, "/sdcard");
            startActivityForResult(intent, SELECT_MULTI_FILE);
        }

    });

    alert.setNegativeButton("NO", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.dismiss();
            askToJoin();
        }
    });

    alert.show();

}

public void askToJoin() {

    AlertDialog.Builder alert = new AlertDialog.Builder(magicContext);
    String choiseString = "";
    if(lastEncrypt == true) {
        choiseString = "Encrypt";
    }
    else {
        choiseString = "Decrypt";
    }

    alert.setTitle(choiseString +" Files?");
    alert.setMessage(choiseString + " The Following Files?");

    // Set an EditText view to get user input
    final EditText input = new EditText(magicContext);
    input.setEnabled(false);
    input.setLines(10);
    input.setVerticalScrollBarEnabled(true);

    String alertBoxString = "";

    for (int i = 0; i &lt; magicNamesVector.size(); i++) {
        try {
            alertBoxString += magicNamesVector.get(i) + "\n";
        } catch (Exception e) {

        }
    }
    input.setText(alertBoxString);
    alert.setView(input);

    alert.setPositiveButton("YES", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            magicJoin();
            dialog.dismiss();









        }

    });

    alert.setNegativeButton("NO", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.dismiss();
            magicNamesVector.clear();
        }
    });

    alert.show();

}


public void changeFileNameText(String newFileName) {
    TextView t = (TextView) findViewById(R.id.fileText);
    t.setText(newFileName);
}

public void magicJoin() {
    // do something when the button is clicked
    AlertDialog.Builder alert = new AlertDialog.Builder(
            magicContext);

    alert.setTitle("Password");
    alert.setMessage("Please Enter A Password For Files");

    // Set an EditText view to get user input
    final EditText input = new EditText(magicContext);
    alert.setView(input);

    alert.setPositiveButton("Ok",
            new DialogInterface.OnClickListener( ) {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String tempName = input.getText().toString();

                    if (tempName.length() &gt; 0) {
                        password = tempName;
                        magicJoinStageTwo();


                    } else {
                        Toast.makeText(getBaseContext(),
                                "Invalid Password!",Toast.LENGTH_LONG).show();
                    }

                }

            });

    alert.setNegativeButton("Cancel",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,
                        int whichButton) {
                    // Canceled.
                    magicNamesVector.clear();
                }
            });

    alert.show();

}

public void magicJoinStageTwo() {
    for(int i = 0;i &lt; magicNamesVector.size();i++) {
        try {
            filePath = (String) magicNamesVector.get(i);
        } catch (Exception e) {
            return;
        }
        if(lastEncrypt == true) {
            scrambleFile(false);
        }
        else {
            scrambleFile(true);
        }
    }
}




            new code---------------------








                       String startPath = getIntent().getStringExtra(START_PATH);
    if (startPath != null) {
        getDir(startPath);
    } else {
        getDir(root);
    }
}

private void getDir(String dirPath) {

    boolean useAutoSelection = dirPath.length() &lt; currentPath.length();

    Integer position = lastPositions.get(parentPath);

    getDirImpl(dirPath);

    if (position != null &amp;&amp; useAutoSelection) {
        getListView().setSelection(position);
    }

}

private void getDirImpl(String dirPath) {

    myPath.setText(getText(R.string.location) + ": " + dirPath);
    currentPath = dirPath;

    item = new ArrayList&lt;String&gt;();
    path = new ArrayList&lt;String&gt;();
    mList = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();

    File f = new File(dirPath);
    File[] files = f.listFiles();

    if (!dirPath.equals(root)) {

    //  item.add(root);
    //  addItem(root, R.drawable.folder);
    //  path.add(root);

        item.add("../");
        addItem("../", R.drawable.folder);
        path.add(f.getParent());
        parentPath = f.getParent();

    }

    TreeMap&lt;String, String&gt; dirsMap = new TreeMap&lt;String, String&gt;();
    TreeMap&lt;String, String&gt; dirsPathMap = new TreeMap&lt;String, String&gt;();
    TreeMap&lt;String, String&gt; filesMap = new TreeMap&lt;String, String&gt;();
    TreeMap&lt;String, String&gt; filesPathMap = new TreeMap&lt;String, String&gt;();
    for (File file : files) {
        if (file.isDirectory()) {
            String dirName = file.getName();
            dirsMap.put(dirName, dirName);
            dirsPathMap.put(dirName, file.getPath());
        } else {
            filesMap.put(file.getName(), file.getName());
            filesPathMap.put(file.getName(), file.getPath());
        }
    }
    item.addAll(dirsMap.tailMap("").values());
    item.addAll(filesMap.tailMap("").values());
    path.addAll(dirsPathMap.tailMap("").values());
    path.addAll(filesPathMap.tailMap("").values());

    SimpleAdapter fileList = new SimpleAdapter(this, mList,  
    R.layout.file_dialog_row,new String[] { ITEM_KEY, ITEM_IMAGE }, new int[] {
                    R.id.fdrowtext, R.id.fdrowimage });

    for (String dir : dirsMap.tailMap("").values()) {
        addItem(dir, R.drawable.folder);
    }

    for (String file : filesMap.tailMap("").values()) {
        addItem(file, R.drawable.file);
    }

    fileList.notifyDataSetChanged();

    setListAdapter(fileList);

}


private void addItem(String fileName, int imageId) {
    HashMap&lt;String, Object&gt; item = new HashMap&lt;String, Object&gt;();
    item.put(ITEM_KEY, fileName);
    item.put(ITEM_IMAGE, imageId);
    mList.add(item);
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    File file = new File(path.get(position));

    if (file.isDirectory()) {
        unselect();
        if (file.canRead()) {
            lastPositions.put(currentPath, position);
            getDir(path.get(position));
        } 

    /*  else {
            new AlertDialog.Builder(this).setIcon(R.drawable.icon)
                    .setTitle(
                            "[" + file.getName() + "] "
                                    +  
   getText(R.string.cant_read_folder))
                    .setPositiveButton("OK",
                            new  
 DialogInterface.OnClickListener() {

                                @Override
                                public void  
   onClick(DialogInterface dialog,

    int which) {

                                }
                            }).show();
        }
        */
    } else {
        selectedFile = file;
        v.setSelected(true);
        selectButton.setEnabled(true);
    }
}
</code></pre>
