Can I download an SQLite db on /sdcard and access it from my Android app?

前端 未结 5 1730
春和景丽
春和景丽 2020-11-30 18:38

I already found out that there is no way to bundle files in an .apk and have them on /sdcard, the best option so far being to download the large files upon first run. I came

5条回答
  •  春和景丽
    2020-11-30 19:37

    Sure you can. The docs are a little conflicting about this as they also say that no limitations are imposed. I think they should say that relative paths are to the above location and dbs there ARE private. Here is the code you want:

    File dbfile = new File("/sdcard/mydb.sqlite" ); 
    SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
    System.out.println("Its open? "  + db.isOpen());
    

提交回复
热议问题