Explain location of Database Files with SQLite
Hello!
I want to connect my database in my future Android ( .apk ) application. The connection with this database is good on Unity project and playmode.
But when I export it on .apk or .exe (computer), I have no more database information on my application.
I tried and test solutions such as, but I do not understand too much these concepts.
Application.streamingAssetsPath
Application.datapath
WWW variableReader = new WWW(pathofdatabase);
I learn : "The file or database must be placed in the Streaming Assets folder for Android to find it."
After all it, the problem is not still solved. I would have liked the explanations on various manners to make.
This is my "BDD.cs" Sorry for this presentation but it's my first post. using UnityEngine; using Mono.Data.Sqlite; using System.Data; using System.Collections; public class BDD : MonoBehaviour { public static IDbConnection DBconn; // Use this for initialization void Start () { string connexionBDD = "URI=file://"+ Application.streamingAssetsPath +"/userbdd.s3db"; Debug.Log (connexionBDD); DBconn = new SqliteConnection(connexionBDD); DBconn.Open(); InfosUser (); } public static void InfosUser () { IDbCommand DBCommande = BDD.DBconn.CreateCommand(); string RequeteAllDonneesUser = "SELECT * FROM Utilisateur"; /*"SELECT * FROM Utilisateur";*/ DBCommande.CommandText = RequeteAllDonneesUser; IDataReader reader = DBCommande.ExecuteReader(); while (reader.Read()) { int valueMeilleurScore = reader.GetInt32(2); int valuenombreGemmes = reader.GetInt32(3); int valuenombreParties = reader.GetInt32(4); PersoControls.meilleur_score = valueMeilleurScore; PersoControls.nb_Parties = valuenombreParties; PersoControls.nb_Gemmes = valuenombreGemmes; break; } reader.Close(); DBCommande.Dispose(); }
The database contains 4 files (idUser, score,...) and the table and fields are created before.