Android Question ProgressDialog while running a Sql Query

BarryW

Active Member
Licensed User
Longtime User
Hi Masters, is there any way how to show a progress dialog while running a sql query then hides it upon complete. i try to use a timer to delay and show the progressdialog while running a query and hides it. my problem is before completing the query the progress dialogs hangs then hide. I have a sql database that has 35700 rows. What is the proper way to do it without hang. Hope someone can help. Tnx
 

keirS

Well-Known Member
Licensed User
Longtime User
I would like to know that as well. You shouldn't need any progress dialog for querying a data set that small.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
This is what I do:
B4X:
ProgressDialogShow("Stand by. Lots of records")
For i=0 To Cursor1.RowCount-1
  Cursor1.Position=i
  MyListView.add(…..'  or whatever you want to do
  If i Mod 100 = 0  Then DoEvents   'the 100 can be changed
Next 
ProgressDialogHide
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
that's the ideal way to solve slow stuff like that but we don't know if he's just filling a listview or is doing some other stuff that could be improved.
 
Upvote 0

BarryW

Active Member
Licensed User
Longtime User
I would like to know that as well. You shouldn't need any progress dialog for querying a data set that small.
Adding a progressdialog on query is for formal presentation than the program is running a query and if i not use a progressdialog then the android just hang nothing to display until it finishes the query. hope you understand.
 
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
Adding a progressdialog on query is for formal presentation than the program is running a query and if i not use a progressdialog then the android just hang nothing to display until it finishes the query. hope you understand.

If you are doing a SELECT and it's taking so long that you require a progress dialog for the query then you are quite probably doing something wrong. Selecting 35700 rows into a cursor just doesn't take that long unless you are doing something really really complex with multiple sub queries?

If the query is taking that long you should show your dialog then use ExecQueryAsync to run your query off the main thread and then hide the dialog when the QueryComplete event is called.
 
Last edited:
Upvote 0
Top