Want to optimize my android app performance
<p>I am developing an android app with an edittext which enables users to search songs. I want to incorporate an instant search in it. I mean I want the search results in my listview of my app to appear instantly as the user types in the edittext box in order of most visited songs . I am using a DB of songs containing field  Songhit for it but I am afraid it may be too slow to process database each time a character is typed. Besides I want my edittext listner to slow down and wait till the user completes his text I am using <code>System.currentTimeMillis()</code> as marker and wait for .5 seconds but it's not waiting. I am new to android and dont know wheather it will work or not. I Need suggestion from someone having some experience with android app programming.</p>

<p>My code: 
Edittext listener: </p>

<pre><code>public void onTextChanged(CharSequence s, int start, int before, int count) 
           {
               currentTime=System.currentTimeMillis();
               if(currentTime - lastTimeTextChanged &gt; 500)
               {  // do smthing  serach song        }   
lastTimeTextChanged =      currentTime;

}    
</code></pre>

<p>It looks ok but it didn't worked... I want to trigger a search only when user stopped typing for say .5 sec. I was wondering if I could overrise setTextFilter() method please help with this as well as performace optimization.</p>
