My app's UI hanged
<p>I am writing an android app, in which I have 1 <strong>button</strong> and 1 <strong>progress bar</strong> as UI elements. </p>

<p>The main aim of this app is when user presses this button, it has to create a database which contains all phone book contacts in customized format, means I am reading Contacts database and manipulating for my requirement.</p>

<p>So I am using <strong>SQLiteOpenHelper</strong> for database operations. I written a method <strong>downloadPhonebook()</strong> to perform all required operations. I written app such that when user presses button I am making progress bar visible and calling this method. </p>

<p>In this case, UI was hanged after clicking button and showing a dialog with <strong>Force Close</strong> and <strong>Wait</strong> buttons, after 15 seconds.</p>

<p>To avoid this I tried following mechanisms.</p>

<p>-> Broadcast Button click message and call method downloadPhonebook(). Here no use, same problem occurred.</p>

<p>-> Used a Thread and AsyncTask to call this method, here I got Runtime exceptions like <strong>Couldn't create Handler inside a Thread, Looper.prepare not called</strong>. I tried calling Looper.prepare() and Looper.loop() even exceptions occurred.</p>

<p>-> I tried with Android Service and Broadcast intent, again same problem UI hanged.</p>

<p>If anybody faced this problem or knows the solution or knows how to use Looper.prepare and Looper.loop please reply me. Thanks.</p>
