How does android access a sqlite database included in the assets folder

后端 未结 5 1240
借酒劲吻你
借酒劲吻你 2020-12-18 07:31

I already have a SQLite database. I put it in the assets folder of my project. I read the Android documentation. It said that for all the databases in Android,

5条回答
  •  别那么骄傲
    2020-12-18 07:37

    When I try to open my DB, I get "unable to open database file". I assume its not finding the DB and not some other programmer error. In the log I see the following which looks good to me.

       sqllite3_open_v2("/data/data/com.isildo.HelloListView/databases/ListsDB" ...
    

    This is the setup

    private static String DB_PATH = "/data/data/com.isildo.HelloListView/databases/";    
    private static String DB_NAME = "ListsDB";
    

    In my projects assets in the Package Explorer, I see the ListsDb database.

    So I at least think I have it all correct. I am using the example at [http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/]

    In one of the posts here, someone offers a suggestion about setting some Assets parameters. {no response to post there}

    **To get an ASSETS folder into your APK:
      In /nbproject/project.properties, 
         change assets.dir=
    to
         assets.dir=assets 
         assets.available=true
    In /nbproject/build-impl.xml, there is line in the “if=assets.available” target that reads
    that needs to be changed to**
    

    Is this something we need to do, and if so, can we get a little better direction on the changes required. I could not find the places to make the suggested changes I looked at the project settings, and other things.

    Yep, Im new to the environment, so I may just be not finding them. Im using Eclipse on windows.

提交回复
热议问题