r/androiddev • u/Adamstrad • Oct 16 '26
Struggling with using webview for a html jscript file which reads local CSV files + saves local user data
Struggling with getting my head around webview.
I have an application which is a one page html javascript page however it needs to read csv files and make some kind of local storage to save the user's progress. What code would I need and where for an app like this as a minimum?
I've tried a few times, including using Gemini but I keep getting errors and things not working even when the syntax seems correct in android stuido.
I did the kotlin android material on the site to learn the basics but there seems to be a lot of other documentation to search through that makes my head spin, is this normal? I thought webview would be easier than creating it in kotlin originally but now I'm starting to feel like I should just scrap it and code it again. I am in science but not educated in computer science formally, any help is welcome.
3
u/Bendoair Oct 16 '26
It is generally recommended to not use webview. Is it absolutely neccessary? If not, you might want to bite the bullet and make tha swap.
1
u/DayanaJabif Oct 16 '26
If your app is already written in HTML and JavaScript, you probably don't need to rewrite it in Kotlin.
I'd look into Capacitor. It lets you reuse your existing web app and run it as a native Android (and iOS) app, with plugins to access native device features.
For your use case, you could use a File Picker to let users select their CSV files, and
localStorageto save simple progress data locally.That way, you can keep most of your existing HTML and JavaScript instead of having to learn Android development from scratch. It's still a learning curve, but hopefully a much smaller one!
1
u/HuckleberryAny3906 Oct 17 '26
you dont really need to rewrite it in kotlin tbh. the two things that trip people up: file urls get blocked so loading the csvs from assets fails, and localStorage is off by default look up WebViewAssetLoader in the androidx webkit docs, it serves your assets folder over a fake https url so fetch works normally. then turn on dom storage in the webview settings and localStorage keeps the progress betwen launches. the android docs page on loading in-app content walks thru it pretty much step by step