2

The structure of DB Dictionary includes two columns: KEY and VALUE. When I press a key, it takes about 2s to finish finding suggestion keywords for my dictionary. But if a user presses 5 words continuous, what will happen. If I press a key, after that my queries is executed, but it causes my Virtual keyboard to crash, cannot add a new key press until the query is completed. If I used UI thread, it will cause deadlock. Can anyone help me in this matter?

UPDATE: I combine the two methods: index and Thread with queues. I add a new word when press a key with queues. I query the order from the queue and delete its value in front of the queue. when the user press a key repeatedly, it will query the last element of the queue. And i used keyword synchronized to avoid errors cursor index out of bounds "index -1 requested: with size 1024" with multithread

judgement
  • 437
  • 3
  • 12

3 Answers3

0

Actually you are looking for locking the textbox or getting the data without crash? If you use ajax with javascript i think you will get a better answer.

BINU VARGHESE
  • 364
  • 1
  • 4
  • 16
0

Make sure your Key column is indexed, see the SQLite CREATE INDEX page.

Silas Parker
  • 8,017
  • 1
  • 28
  • 43
  • Thanks for your help. I used index but it ineffective. I think the solution is use thread but how to avoid deadlock – judgement Nov 21 '11 at 09:41
0

You could probably use a AsyncTast for the query. This will reduce the impact on the UI thread. But you can't stop an AsyncTask abruptly, although you can follow this.

Hope this gives you an idea to go ahead.

Community
  • 1
  • 1
c05mic
  • 558
  • 5
  • 18