SQLite Android . unable to open database file

前端 未结 2 624
刺人心
刺人心 2020-12-19 05:01

I found a lot of question about this problem, but i can\'t fix it. I have a sqlite db in assets folder:

assets/data/data/{package_name}/databases/mydb.db


        
相关标签:
2条回答
  • 2020-12-19 05:56

    Instead of hard coded DB_PATH (no longer work in JB), I would recommend always go with Android inbuilt API method,

    mContext.getDatabasePath(DATABASE_NAME).getPath();
    
    0 讨论(0)
  • 2020-12-19 06:00

    Look at this tutorial

    It Explains how to work with preloaded database. Basically you can't use database right from the assets, you have to copy it over into internal data storage first and open it from there

    0 讨论(0)
提交回复
热议问题