Issue
I am creating a simple Android Bible app. Bible text is structured in the bible
folder as:
.
├── bible
│ ├── book_one
│ │ ├── chapter_one.html
│ │ ├── chapter_two.html
│ │ └── [...]
│ ├── book_two
│ │ ├── chapter_one.html
│ │ ├── chapter_two.html
│ │ └── [...]
│ ├── [...]
| [...]
[...]
My question are:
- where is the appropriate place to put the
bible
folder in Android app project and, - how do I import it with the Android Studio (version Artic Fox) and,
- how do I load those files to use it within my code?
P.S. I'm new in the Android app dev world.
Solution
In order to put HTML files in your existing android studio project please follow steps below:
1: To add a local HTML file into your Android project there must be an asset folder in it. To create an asset folder in Android studio open your project in Android mode first as shown in the below image.
2: Go to the app > right-click > New > Folder > Asset
Folder and create the asset folder.
3: Android Studio will open a dialog box. Keep all the settings default. Under the target source set, option main should be selected. and click on the finish button.
4: The asset folder has been created as shown in the below image. Go to assets > right-click > New > File
and a dialog box will pop up.
5: Provide a name to your file as shown below. For example demo.html
6: Or you can simply paste your html files into assets folder created in step 4.
7: You are done with it! Happy Coding
8: This way you can use your files from Assets folder:
webView.loadUrl("file:///android_asset/filename.html");
Answered By - Deep Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.