Get databases directory for my app programmatically

前端 未结 5 1547
孤城傲影
孤城傲影 2020-12-10 12:20

I want to use a \"pre loaded\" database in my app. There are tons of questions about this and most point to this blog article here or similars.

So far so good. I jus

5条回答
  •  情深已故
    2020-12-10 13:14

    Used by SQLiteAssetHelper:

     String path = mContext.getDatabasePath(mName).getPath();
    

    At this time, the database doesn't exist. I think the String just takes the internal path and adds the appropriate modifiers. In fact, this seems to work just fine:

    context.getDatabasePath("a").getParentFile()
    

    Basically, you don't need to have a real database created, just ask it for one.

提交回复
热议问题