Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread Alok Kulkarni
Problem Solved.. The problem was that i was querying on the tracks database for 1000 songs.. At the same time, scrolling the list would make a call to the same tracks table. This is synchronous in Android using the same DB object. So the solution was to create a seperate DB object as getReadableDat

Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread Alok Kulkarni
Yess :( Anyone can try it out.. One more thing.. I have iniialised the DB ie called the getWritiabledDatabase at the start of app from the Application class.Is the accessing the DB from a new thread causing the UI to hang if supposedly the Application context means the UI context getting blocked a

Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread Mark Murphy
On Tue, Jul 20, 2010 at 8:24 AM, Alok Kulkarni wrote: > Thanks for your reply. What i did was i removed the System.gc() as well as > the handler call. > Considering the codeĀ  from above snippet. > > Log.i("VALUE->", "Before movetoFirst" + > System.currentTimeMillis()); > mCursor.move

Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread Alok Kulkarni
Hi Mark, Thanks for your reply. What i did was i removed the System.gc() as well as the handler call. Considering the code from above snippet. Log.i("VALUE->", "Before movetoFirst" + System.currentTimeMillis()); mCursor.moveToFirst(); Log.i("VALUE->", "After movetoFirst" +

Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread Mark Murphy
With respect to your " If i dont do a Thread.sleep... the UI gets completely blocked until all the records are fetched.", the problem would appear to be in whatever your Handler is doing, or possibly just due to all the garbage collection you are doing. None of the code you show here, other than th

Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread Alok Kulkarni
Hi Mark, As i said , i am doing the operation in a "background thread". I also know that cursor.moveToFirst() causes the data to be accessed at that point. Here is the code public void getAllSongIdsOffset(int offset, int limit) { int nTrackId; try { SQLiteDatabas

Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread anil kukreti
Ya Mark is right ! You need to use *multithreading* for making a reponsive UI. Thread.sleep inside spawned thread will give a chance to main UI thread to response to User events. -- Forwarded message -- From: Alok Kulkarni Date: Tue, Jul 20, 2010 at 4:44 PM Subject: [android-de

Re: [android-developers] cursor.moveToFirst() blocking UI

2010-07-20 Thread Mark Murphy
On Tue, Jul 20, 2010 at 7:14 AM, Alok Kulkarni wrote: > I have a background thread which queries for 1000 records at a time. After > querying , when i call cursor.moveToFirst(), the UI gets blocked until the > operation is completed. When you call query() or rawQuery(), the query is not actually