1. Are you ready for the Galaxy S20? Here is everything we know so far!

[SQLite] Stuck for hours trying to figure out how to access database in /assets/

Discussion in 'Android Development' started by bw91, Dec 5, 2013.

  1. bw91

    bw91 Lurker
    Thread Starter

    Here's the scenario:

    • I have an app that will load a list of movies from a local SQLite database (& description, release, etc)
    • I'm using the Master Detail Flow template (rather than BlankActivity)
    • I have the SQLite database created and stored in the /assets directory of the project
    • I have a DatabaseManager.java that is suppose to facilitate database actions.

    My problem: I'm getting the following error when I would try to open my database:
    Failed to open database '/data/data/com.jonny/databases/database'.

    Here is my source code: http://www.mediafire.com/download/vxzwiidypi111bt/MovieListActivity.zip (I'd pastebin it, but I'd rather you see the context)

    Here is the guide I was using: Android Database Tutorial | My Android Solutions

    I'm quite desperate for a solution, close to the point where I would pay a tutor to walk me through it. :thumbup:

    1. Download the Forums for Android™ app!


  2. timcs

    timcs Member

    I think the DB_PATH in your case should be [HIGH]/data/data/com.jonny.moviestar/databases/database[/HIGH] as reading the tutorial this is your main package in the android manifest as the example from your link indicates that the main package in that is com.example.


    alostpacket likes this.
  3. mills2533

    mills2533 Well-Known Member

    It would be beneficial for you to familiarize yourself with adb and adb shell so you can look through the directory and files on your phone or emulator depending on which you're using. Then you'd be able to verify where your database was actually installed.
    alostpacket likes this.
  4. alostpacket

    alostpacket Over Macho Grande?

    That's not a good tutorial.

    Try making your db on the device an populating it with just a few rows in code.

    Dont try to add/copy/package a pre-made db

Share This Page