Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Looking for Suggestions for a Database in Android (Unity 5)

Discussion in 'General Discussion' started by PotatoVeg, Jan 28, 2017.

  1. PotatoVeg

    PotatoVeg

    Joined:
    Jan 28, 2017
    Posts:
    12
    Hey guys,
    i am new to Unity, i am self learning it for a month now and i have already created a fully functioning game for Android (nothing crazy but i think its very good for the small amount of time i know unity).
    i am a college student learning Program Engineer and for my final year's project we need to make either an App or a Website, i chose an App and my college is not teaching Unity (its teaching Android Studio) and i have decided to do my Project with Unity and i MUST have a database in my project as it is a requirement.

    i have seen many ppl searching on how to do SQLite Database in Unity for Android and unsuccessfully not achieving it .
    i am not limited in the TYPE of the database (sql, a server, or anything) i can use what ever database i want as long as it saves the data for the user to view or use later on once he closes the app like saving progress and loading it.

    what i need is once a player finishes a game, he has a button to click and add the last game stats (if he won, lost, points etc...) to the database and then in the main menu he has a button to view the ENTIRE history of games he done using the data he inserted to the database in the end of every game.

    Any suggestions on how can i do the entire Database idea?
     
  2. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    SQLite. There are some free assets that somebody put on the asset store (hint: http://u3d.as/8Qn). Of course, there are some paid-for assets, but they'll have bells and whistles you probably won't need/use. You don't even need the asset store actually, just download the files and a little bit of reading.

    Your requirements are dead simple, but you'd probably want to package the database with the application... you could use a flat file even, but for learning sake, I'd just say go with SQLite.

    As for how, err... SQLite for Android uses a .so file, not a .dll. Just need to know what to use and how to interface it.
     
  3. PotatoVeg

    PotatoVeg

    Joined:
    Jan 28, 2017
    Posts:
    12
    the thing is i have already tried this one, and didnt even use any script yet, just tried to run my app and it crashes on startup, if i remove the entire plugin folder from my app and then try to start it up it works, but then im without the DB.. :(
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    The normal use of Unity and databases is for Unity to connect to a remote database. You can do it through WWW calls. Then all of the database stuff exists in its own world.

    Using software you don't know and the Uni doesn't support for your final project is ballsy. I hope it pays off for you.
     
  5. PotatoVeg

    PotatoVeg

    Joined:
    Jan 28, 2017
    Posts:
    12
    well basically i want to become a Game Developer with Unity, i actually finished my project, i have fixed some stuff and now the app IS working even while all the plugins and everything are inside, its doing all well, only problem i have now is the database to actually work, on my PC while trying it inside unity it works fine but while trying it on my android device it just shows nothing like there is some kind of exception and the command in the SQL is wrong or something.
    basically only thing missing is the Database to work and that is it my project is done.

    question : how can i log exceptions or errors that occur on my android device so i can know whats wrong?
     
  6. PotatoVeg

    PotatoVeg

    Joined:
    Jan 28, 2017
    Posts:
    12
    UPDATE!
    i have succeeded on reaching the DB file, open the connection (i have checked if its open or closed, checked if the file existed ofc before opening the connection)
    i have made a command and everything but the thing that causes the exception is :

    Code (CSharp):
    1. rdr = cmd_db.ExecuteReader();
    rdr is type of IDataReader

    now the issue is why is it causing an exception there? the string of the command is simple :
    Code (CSharp):
    1. string sql_cmd = "SELECT * FROM" + " " + db_Name;
    2. cmd_db.CommandText = sql_cmd;
    EDIT
    exception is "NO SUCH TABLE" o_O

    EDIT#2
    ok so i have managed to make it work, i have tested creating a table using the script, deleting a table and so on, the database is being shown properly, only last issue that is appearing is inserting into the table which doesnt seem to work on the android while on the unity editor (pc) it does work.

    EDIT#3
    i forgot to edit the thread, anywho i have finished it like week ago, i have added a 2nd map and made table for each, everything is working perfectly, my project is done and i need to deliver it only more 7months so.... now im bored... need to work on another thing to keep myself busy hahaha

    CAN CLOSE THREAD PLEASE!
     
    Last edited: Feb 8, 2017