0

A related Question is asked here. The tutorials show how to copy the database, but I want to open it directly, So I started with this code but it seems that there is an error that I wasn't able to know

SQLiteDatabase db = SQLiteDatabase.openDatabase("file:///android_asset/quiz.sqlite", null, SQLiteDatabase.OPEN_READWRITE);

I can create a database and work on it and I can copy an existing database an work on it, But how to open it directly from the assets folder?

Cœur
  • 34,719
  • 24
  • 185
  • 251
Khalil Bz
  • 517
  • 9
  • 22

1 Answers1

1

but I want to open it directly

That is not possible, sorry. An asset is not a file. It is an entry in the ZIP archive that makes up an APK. SQLite has no means of working with an asset. file:///android_asset/ is a hack for use with WebView; it does not work for arbitrary other pieces of code.

CommonsWare
  • 954,112
  • 185
  • 2,315
  • 2,367