1

I have HTML page, CSS, JAVA and images all stored in my SQLite database.

I can load HTML from string into WebView but I can't figure out how to add resources like CSS or Java script to that page dynamically. Is there any preferred way other than saving files to file system?

katit
  • 17,375
  • 35
  • 128
  • 256

2 Answers2

2

My suggestion is to create your own content provider and wrap your database access via that provider.

Then later you could register your provider in manifest such as:

<provider android:name="MyCustomProvider" android:authorities="your.provider.package.name" />

and in WebView you will be able to access resources via content://your.provider.package.name/... schema.

interrupt
  • 2,030
  • 17
  • 14
0

Use the assets folder. You can put your files (including directory structures) into assets folder and retrieve it later.

Note that you have to point your html to your css using the asset path.

Example: Webview load html from assets directory

Community
  • 1
  • 1
Calvin
  • 3,302
  • 2
  • 32
  • 41