How to read local JSON file with Phonegap + jQuery Mobile

While working on my Phonegap project I wanted to load initial data into SQLite. One option is to download it from the internet, but it’s always annoying to notify the user to turn on internet and to wait for all the files to download (especially if you have to download 50 images).

The other option is to load local data. Problem is that identifying the right path to local file can be tricky. But the solution is actually easy.

All we need is to get current location, remove index.html to get root folder, append it to path of JSON file and voila.

Hi, I'm Erol
Senior Fullstack Developer

I'm available for hire. So if you need help, send me an email.