Multiple storage solution in one app

Hello everyone,

I’m relatively new to the Ionic Community and I’m looking to implement storage solution for my workout app. After doing my research I think the strength and weaknesses of Ionic Storage, Capacitor Storage, Preferences API and SQLite are clear, however it’s not clear to me if it would be a good practice to combine these solutions or if it’s the right fit for my use case, so I would like the input from the community.

The app should store:

  1. User preferences
  2. Plates inventory (what plates the user has available in the gym)
  3. Records of each workout

Additionally, I will be providing workout performance statistics to the user.

It sounds to me that Preferences API would be the easiest way to story user preferences persistently.

The plates inventory could be stored with Ionic Storage as JSON since each plate only has about 7 properties, although the user will be able to store 100s of plates so I’m not sure how scalable that is. So maybe I should use a SQLite?

Last but not least, for the workout records, since I will be providing statics and need querying, sounds to me that SQLite is the way to go.

On any case, would you recommend to use multiple solutions in one app; Ionic for preferences, Ionic Storage(with SQLite plugin) for inventory, and SQLite for records. Or should I just use SQLite to store everything there? I’m a bit torn right now.

What would be a good way to go about this? Curious of what your thoughts are.

Thank you!


I wouldn’t use this to store user preferences, as it states in the docs: This API is not meant to be used as a local database since mobile OSs may periodically clear data.

Sounds like you already know what you need to do. Go the SQLite way. Also if your build an app like this, which stores lots of workout data from the user, you should look into Secure Storage.

I think you misread the plugin docs :slight_smile: It says to use the Preferences plugin for persistent storage of lightweight data. It should be used over localStorage which might be cleared periodically.

For the OP’s use case, SQLite definitely sounds like the way to go. Might as well use it for everything to keep it simple, preferences, workout data, etc.

Agree on the encryption too. The SQLite community plugin says it supports encryption.

Note : This API is not meant to be used as a local database. If your app stores a lot of data, has high read/write load, or requires complex querying, we recommend taking a look at a SQLite-based solution. One such solution is Ionic Secure Storage, a SQLite-based engine with full encryption support. The Capacitor Community has also built a number of other storage engines.

I see where it could it be misread, thanks :slight_smile:, but depending on the case, user data is not lightweight and most definitely shouldn’t be used to store sensitive info like user data.

ios user defaults:
The parameters are referred to as defaults because they’re commonly used to determine an app’s default state at startup or the way it acts by default. The defaults system allows an app to customize its behavior to match a user’s preferences.

android shared preferences:
SharedPreferences is not recommended for storing data that is sensitive to this kind of rollback to a prior state such as user security or privacy settings. SharedPreferences is best suited to storing data about how the user prefers to experience the app

If it’s minor data without sensitive information sure or passing data over to get in another component, sure why not. But OP hasn’t gave us enough info on what the user data is :slightly_smiling_face:.

Also good to note, that its best to have 1 type of storage library to handle all these uses cases.

Fair enough, makes sense :grin: For user preferences, I was thinking just general app preferences, light/dark mode preference, a preferred audio voice, auto advance or not, etc. As you said, we don’t know what the OP is looking to store here. Anything other than simple general preferences, 100% agree with you. Go with something more secure and robust.

@Hills90210 @twestrick thank you so much for your answers. I will go with your suggestion of using SQLite and keep it simple. And also will do encryption to protect user’s information.

To share more insight I will be storing stuff like user’s height and weight, preferred metric(kg vs lb) and some other simple configurations for the app.

Appreciate the help y’all.