Questions regarding SQL Server / MySQL and mobile platform

So I’ve been able to connect monogame/xamarin directly with my own computer’s hosted SQL Server and perform basic commands like reads/writes/update - which I think is all I need.

There are several questions I couldn’t wrap my head around and I feel like I’m missing something that tutorials assumes you know. These questions stemmed mainly from me not having done it before and have no one to ask.

1. How can I ensure the specific user logging in from the Play Store or App Store will definitely be reusing the same row? Is there a unique customer number that is provided to me by the Play Store / App Store to which I use it to place them in a table and start my own unique index and increment from there?

2. I have password, login, IP address displayed in a connection.cs file in order to connect into the SQL Server. Will this cause a security problem or is it completely normal to have every installation get a copy of my SQL Server’s IP address, password, login?

3. In order to also save locally to their device for offline play, is it standard to have say sqlite embedded in their device and an SQL Server option on top of it and then switch between the two SQL tables depending on their connection? Or is there a better way to implement it? This isn’t a multiplayer game, but the data are user config, their unique records, etc.

4. If I have an in-app purchase option, do I create a boolean column and set it to true if they paid? Or will I be doing something unnecessarily redundant that Google/Apple already have in place? Typically, are in-app purchases simply a true/false switch from within some config file? Wouldn’t that be simple to hack if coders know where to look?

Appreciate the answers in advance.

You probably need to add a login to your app. Once the user is logged in you have a unique id. Could be the user name, email, or some id from the server. You can use Google’s or Apple’s login systems, or run your own. Since recently Apple forces you to also have Apple Sign-In in addition to your own login (with some exceptions), so the easier path is to just use the Apple system there.

Normally an app sends requests to a server, which then queries the database, and sends back a response.

I think it’s not uncommon to use something like sqlite for that, but you could also use the standard local storage functions the OS provides.

Apple and Google have systems for in-app purchases. Check their SDK’s/Docs.

It is bad form to save connection information within your app. It is much better to store it in an App.config file. You then use the System.ConfigurationManager.ConnectionString to read the connection details. Another alternative is to save the connection details in an encrypted file within your app. Know that Android does not support MySQL (noticed that in your title.) A more secure option for your connection is to develop a web API and query it for your SQL queries rather than running them directly from your app (I use the approach.)