简体   繁体   中英

How to connect to a SQL Database on an Android Kotlin app

I am building an Android application with Kotlin. I am not very familiar with Databases and Backend in general, I have only used AWS DynamoDB and S3. I want to try something else and learn SQL. I want to connect my app to a Cloud SQL DB like MySQL or PostreSQL. I can't use SQLite because I want the app to be served remotely and be accessible by all the users. I don't need a server, instead I would like to use a server-less structure where I make queries to the DB on function calls from inside my App. How would I do that? I read online about services like planetscale and raiway.app but I can't find a way to connect to my tables there. Are they perhaps web-only?

If you have a remote back-end you can use retrofit https://square.github.io/retrofit/ otherwise you can use room library https://developer.android.com/training/data-storage/room .

I understand that you aren't going to use a Server but in the case where you have to make queries locally, ie you have your database on your PC, you must use retrofit and for doing this you must make a small API that will send you JSON and you can process your queries easily with that. If not, you can use room to connect to sqlite, a small database that is default on android phones.

Some Links:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM