Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ricardohenrique996 · Jan 31, 2016 at 02:36 PM · androidunity5sqlite

Sqlite database doesn't work on Unity games build to Android Devices

I'm using the Sqlite as Unity Game database and works on Unity Editor, but when I build to Android Devices the Game can't access the database, what can I do to make the script works also on Android Devices ?

Programs/Versions used:
- Unity 5.3.1f1
-Sqlite Precompiled Binaries for Windows 64 (sqlite-dll-win64-x64-3100200.zip (688.01 KiB))

Folder Structure:

 -- Assets/Database/MyDataBase.db
 -- Assets/Scripts/PerguntaScript.cs
 -- Assets/Plugins/Mono.Data.Sqlite.dll
 -- Assets/Plugins/sqlite3.def
 -- Assets/Plugins/sqlite3.dll
 -- Assets/Plugins/System.Data.dll

PerguntaScript.cs (Script that access the Sqlite database)

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using System;
 using System.Data;
 using Mono.Data.Sqlite;
 
 public class PerguntaScript : MonoBehaviour {
 
     private string connectionString;
 
     void Start () {
         connectionString = "URI=file:" + Application.dataPath + "/Database/DoencasDB.db";
     }
 
     private void GetPergunta(){
         using(IDbConnection dbConnection = new SqliteConnection(connectionString)){
             dbConnection.Open();
             
             using(IDbCommand dbCommand = dbConnection.CreateCommand()){
                 string sqlQuery = "SELECT * FROM " + sqliteTabelasPerguntas[sqliteIndexTabelaPergunta] + " WHERE doenca_id=@id LIMIT 1";
                 dbCommand.Parameters.Add(new SqliteParameter("@id", doencaId));
                 dbCommand.CommandText = sqlQuery;
                 
                 using(IDataReader reader = dbCommand.ExecuteReader()){
                     while(reader.Read()){
                         pergunta = reader.GetString(1);
                         alternativasId[0] = reader.GetInt32(3);
                         alternativasId[1] = reader.GetInt32(4);
                         alternativasId[2] = reader.GetInt32(5);
                         alternativasId[3] = reader.GetInt32(6);
                         alternativaCorretaId = reader.GetInt32(7);
                     }
                     dbConnection.Close();
                     reader.Close();
                 }
             }
         }
     }

Comment
Add comment · Show 1
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 kaiowa · May 16, 2016 at 02:53 PM 0
Share

I have the same problem. But when i copy this dll into Plugins folder, nothing happens, same result.

in my Plugins folder i have following dlls:

 -I18N.dll
 -I18N.West.dll
 -$$anonymous$$ono.Data.Sqlite.dll
 -sqlite3.dll
 -sqlite4.dll
 -System.Data.dll

any help plz?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by insertcoinp1 · Mar 15, 2016 at 08:50 PM

I would guess that the problem is that you are using a 64-bit driver. I know that most Android devices still use a 32-bit ARM processor ... I think only about 5% of the market uses 64-bit. Even though we are talking an x64 windows binary, I'd give the 32 bit one a shot and see if that works.

Comment
Add comment · 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
0

Answer by Falcon_DZ · Mar 16, 2016 at 11:47 AM

@ricardohenrique996 your DB works fine in editor because they will have some dll files which will connect DB with your project but when you build them the dll files will not be exported along with your project. the solution is create folder called as Plugins in assets folder and copy the dll files " I18N.dll" and " I18N.West.dll". then build project it will work fine.

Comment
Add comment · 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

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

SqliteException: SQLite error no such table 1 Answer

[Unity] Problem with SQLite on Android 2 Answers

How to create a SQLite database in Android 0 Answers

Reading XML Data for andriod 1 Answer

SQLite works fine in Unity Editor but doesn't work in Android device (apk). 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