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
3
Question by grzekos · Jun 13, 2015 at 01:49 PM · androidunity 5unity5sqlite

[Unity] Problem with SQLite on Android

Hello, I have been trying to get SQLite to work on my Android device for days now. First of all, I want to point out, that everything works fine on the computer. I can read and write to the created SQLite database with no errors.

The problem starts when I export the project to .apk and install it on my Android device. When I'm trying to do anything involving the databse, nothing is happening.

The logcat message: alt text

What have I done to this point:

  1. Downloaded and put sqlite3.dll to Assets/Plugins folder

  2. Copied System.Data.dll and Mono.Data.Sqlite.dll from Unity\Editor\Data\Mono\lib\mono\2.0 folder to Assets/Plugins folder in my project

  3. Created database using 'SQLite Administrator tool' and put it in the Assets folder

  4. Created Assets/Plugins/Android folder and put libsqlite3.so in it

As I said before, this works perfectly fine on the computer (in the Unity Editor), but not on the Android device.

I was looking for the solution everywhere, but in most cases putting libsqlite3.so to the Assets/Plugins/Android solved the problem. Any help will be appreciated.

error.png (52.4 kB)
Comment
Add comment · Show 3
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 Murzynas · Jun 13, 2015 at 02:40 PM 0
Share

I've got exactly the same problem and can't find working solution anywhere ;/

avatar image SV_Janjo · Jul 10, 2017 at 02:51 PM 0
Share

So... how did you do it @grzekos ? Did you found the solution? Have similar problem...

avatar image SaturnoMichael · Aug 30, 2017 at 05:14 PM 0
Share

Hello, you solved the problem, it happens to me too. This is the code I use.

  try
         {
             string conn = "URI=file:" + Application.dataPath + "/Base de Datos/Catalogo.s3db"; //Path to database.
             Debug.Log(conn);
             IDbConnection dbconn;
             dbconn = (IDbConnection)new SqliteConnection(conn);
             dbconn.Open(); //Open connection to the database.
             IDbCommand dbcmd = dbconn.CreateCommand();
             string CodigoCategoria = VariablesGlobales.codigoCategoria != null ? VariablesGlobales.codigoCategoria : "ninguna";
             string sqlQuery = "select  codigoCategoria,NombreCategoria  from Categorias where codigoCategoria='" + CodigoCategoria + "' ";
             dbcmd.CommandText = sqlQuery;
             IDataReader reader = dbcmd.ExecuteReader();
             if (reader.Read())
             {
                 string codigoCategoria = reader.GetString(0);
                 string NombreCategoria = reader.GetString(1);                
                 TituloCategoria.text = NombreCategoria;
             }
             reader.Close();
             reader = null;
             dbcmd.Dispose();
             dbcmd = null;
             dbconn.Close();
             dbconn = null;
         }
         catch (Exception exe)
         {
             Debug.Log(exe.$$anonymous$$essage);
         }

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by houseyokeswaran · Aug 30, 2017 at 06:42 PM

Try putting the database in StreamingAssets folder or use file I/O and save it to Application.PersistantDataPath

Seems like it's also not able to find the actual sqlite dll though. Could be that the dll is not supported on Android.

https://github.com/Busta117/SQLiteUnityKit

I've used this library with success for compiling on Android

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 unity_l4OYzPsro56_rQ · Oct 08, 2017 at 01:12 PM

http://answers.unity3d.com/answers/1414644/view.html

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

8 People are following this question.

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

Related Questions

Need to Include a file in the build and use it in the runtime 0 Answers

Unity stalls when pushing obb expansion file to Android device 0 Answers

Building Unity game that includes SQLite database ,How to build Unity game that includes SQLite Database. 3 Answers

SqliteException: SQLite error no such table 1 Answer

Sqlite database doesn't work on Unity games build to Android Devices 3 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