change progress dialog android while is it showing code example
Example: progressdialog not showing android
Instead of doing this in one function at once. Do the following steps and
it will definately work for you.
1. Create one async class.
(It will create one separate thread for
your copy directory functionality and wont run on main UI.)
2. Show your progress dialog before you execute the async class.
3. On post execute method, dismiss your dialog.