Storing the pages of a book within ionic app

I’m building an app which includes the ability for users to read through a book in an e-reader format. My question is, where do I store all of the text data which makes up the book?

I’ve tried a couple of things: Storing the pages as .json files in the assets folder.
I stopped trying with this method as I’ve read that the path to the assets folder changes depending on which device the app is loaded on. My app will be multiplatform so this put me off. Also, making http requests to within my own app seems a little ridiculous.

Importing json files as an import. This doesn’t suit me as the file loaded should change when the user wants to read the next page of the book.

Using Ionic Storage. This solution would be fine if I could find a way for the app to load with all of the book’s data in the ionic storage sqlite database. But I can only write one key and value at a time, and when the app loads for the first time, there’ll be a nasty script where the book’s content gets written into the sqlite database from my ionic_storage_service.ts.

What am I missing here? Any ideas are greatly appreciated! Thanks!

This isn’t necessarily true. Please quote your source.

ionic framework - fetching data from json file in assets folder - Stack Overflow

The solution posted by the OP

Ok, pretty sure assets in asset folders can be reached using single path.

This post is 4 years old, btw. And from the face of it there could be multiple things going wrong there

So, imho, assets folder are neatly bundled and accessible in the same way creating a nice developer experience across platforms

But maybe someone can confirm out of a recent deployment via cordova or capacitor to ios and android?

From my end I can confirm it works flawlessly on Pwa across platforms

What is your deployment target?

Hi thanks for your response. I think you’re right that the assets folder should be reachable with a single path. Deployment target is Android, iOS, PWA. I’ll update this thread once I’ve built the app in Android Studio to confirm

1 Like