Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Nanou · Aug 06, 2014 at 03:42 PM · androiddatabaseremote

How does one connect an Android app to a remote database?

The question should make it clear. I've got a local database running and in the editor it works perfectly, but now I wonder how to make it connect to a remotely hosted database.

Here is the code I use to make it connect:

     private static void openSqlConnection()
     {
         string connectionString = "Server=localhost;" +
             "Database=pokedex;" +
             "User ID=root;" +
             "Password=;" +
             "Pooling=false";
         dbConnection = new MySqlConnection(connectionString);
         dbConnection.Open();
         Debug.Log("Connected to database.");
     }


I get that User ID and Password would be the user and pass to the database, but I don't know what to fill in in the Server spot. I've practiced a little bit of PHP and with that a database always is on localhost, since usually the PHP files are also on that same server.

But since I'm making an Android app, the database will not be local, but hosted somewhere else. Could anyone give me a clear idea of where I should look? (I've been looking all over the internet, but I can't find anything remotely helping)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by zharramadar · Aug 06, 2014 at 07:30 PM

Well, I don't know if an Android device will have any problems or not directly acessing a MySQL database, I would surely put a webservice layer between the game and the database, but answering to your question, you should put the IP or the URL to the server where the MySQL engine is hosted. Also, the MySQL ports in the server should be open and correctly accepting external requests.

Still, not sure if Android would require anything security-wise to allow you to remotely access ports rather than 80, you would have to check this out too.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nanou · Aug 06, 2014 at 07:57 PM 0
Share

Thank you, it worked like a charm. I don't really think extra security would be necessary, since it is not really a game, more like an information app. People will only click on things and information will appear, they will not enter their own.

avatar image zharramadar · Aug 06, 2014 at 08:20 PM 0
Share

Okay, glad I could be of help =D

avatar image pinkey tanna · Dec 20, 2014 at 06:40 AM 0
Share

it works on any network really!!!!

avatar image AriegoGames · Jul 15, 2015 at 10:10 AM 0
Share

I can't connect my android build with my remote DB :S.. it works on editor but after build the game do not connect. Do you have some example to share? :$

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

SQLite Transaction Update Problem on Android 0 Answers

Unity Remote 5 not connecting to HTC 10 0 Answers

ultility app 0 Answers

Android Mysql Database online 3 Answers

Saving Database from server to local and read from there (android) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges