why my android game lag when getting data from online mysql

hi all, i need your help.

i want to ask, why my game is lag when i get data from online mysql database, how can my game not lag if i want to have database online in it ???

any solution? if yes please help me here. i developed game for android device, using mysql online.


Never direct connect to a database from a game. Everyone that uses your game can read your username / password. Use a webserver + pup to encapsulate the db functions.

In the case that this isn’t a game but an application that should connect to the users local database, you should put database queries into a desperate thread. Using coroutines won’t help here since the database query is like an atomic instruction unless you use asynchronous queries which also uses a seperate thread.

Can you give a bit more details about what you actually do? Is it a game or is it just an application?

I’m more than certain that it lags because it waits for the database reply in the frame you’re in when you call the query. You should not block the game while you wait for your query result. Try putting the connection code and query code into coroutines so you don’t block your game while waiting for them.

Hi quantum_rez,
I work at android app that should connect to online database.
On PC and on unity editor it work; but if i build apk itsnt work.
How u do to work it?
Have u add uses permission in AndroidManifest?