• 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
Question by Unicorn10 · Apr 10, 2019 at 05:02 PM · builddatabasebuild settingsbuild error

Cannot access Sqlite database in final build of the game

When playing my game from the editor, I have no issues with accessing the database, however when I build the game and run it, I cannot access the database. My database is inside the path Assets/Plugins. I should have all the required DLLs in that folder as well. I have checked the output_log.txt file for my game and got the following messages:

 SqliteException: Unable to open the database file
   at Mono.Data.Sqlite.SQLite3.Open (System.String strFilename, SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool) [0x00000] in <filename unknown>:0 
   at Mono.Data.Sqlite.SqliteConnection.Open () [0x00000] in <filename unknown>:0 

T$$anonymous$$s has led me to believe that my database files are in the wrong directory, or I am accessing them incorrectly. Here is the code for how I access the database:

         var RoomDB = new SqliteConnection("Data Source=Assets\\Plugins\\Rooms Table.db;Version=3;");
         RoomDB.Open(); 

If the issue is with the path of the database, where should I move them to inside the final build folder?

Comment

People who like this

0 Show 6
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 siddharth3322 · Jul 05, 2020 at 04:38 PM 0
Share

Any solution for this problem? I have tried all the answers but nothing worked for me.

avatar image xxmariofer siddharth3322 · Jul 05, 2020 at 04:44 PM 0
Share

you need add manually the DB into the final build directory, and after that find the DB

avatar image siddharth3322 xxmariofer · Jul 05, 2020 at 04:46 PM 0
Share

I have added manually DB within the StreamingAssets folder as like the below answers. But I can't able to write URI to access that DB within the code.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by hameed-ullah-jan · Apr 11, 2019 at 07:00 AM

put your .db file in "StreamingAssets" folder, and access it using`path = Application.persistentDataPath + "/StreamingAssets/yourdbfile.db"`

Comment
Bonfire-Boy

People who like this

-1 Show 1 · 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 Bonfire-Boy · Apr 11, 2019 at 10:33 AM 1
Share

That will only work if you have already copied it to persistent data.

avatar image

Answer by kaarloew · Apr 11, 2019 at 06:07 AM

You shouldn't store you database to assets folder since it only usable with Unity Editor. If you want to write files to somewhere, use Application.persistentDataPath https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

Comment

People who like this

0 Show 1 · 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 Bonfire-Boy · Apr 11, 2019 at 10:36 AM 0
Share

You'll also need to put the file there! This can be done e.g. either outside the app or in it by copying from streamingAssets.

Also worth noting that if you're not running on a mobile platform, you're not restricted to that folder. For PC/Mac standalone applications I usually allow the user to choose what folder to save stuff in.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

118 People are following this question.

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

Related Questions

Game is running in unity but it is not running in pc or mobile phone. 0 Answers

Can't build out to iOs10 from Unity 5.4.1 1 Answer

Old build present after building to a new folder on desktop. 0 Answers

[Unity 2017.3.0f3] Cannot open my build it Crashes (with crash Raport) 1 Answer

LOTS of build errros 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