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
  • 37,241
  • 25
  • 195
  • 267
Khalil Bz
  • 557
  • 1
  • 9
  • 24

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
  • 986,068
  • 189
  • 2,389
  • 2,491