Where to place my android app's data

84 views Asked by At

I'm currently developing an app that lets you create and save excercises and routines for the gym. I want the app to come with some example excercises and routines and also to give the user the ability to add his own.

The thing is, I know I can use "getFilesDir()" and save it in the internal memory, but if I do that, how do I put my example files also in the internal memory? I don't think I can do that without creating those files by code everytime the app runs. I've also tried putting the example excercises in "res/raw" but then the ones the user adds go to a different place and I don`t know if that's good practice, apart from just how annoying it is having to read them from different places.

Where would be the best place to put those excercises and routines files? Thank you very much!

4

There are 4 answers

1
Seasia Creative Crew On BEST ANSWER

The best practice is to store data inside "Sqlite Database".
"Sqlite Database" is the internal database that android provides to store data locally and is easy to use.
It's queries are easy to implement. It is more easy to work on, if you have worked on any database before. Just create a "Database Helper" class and initiate inside the activity where you plan to store data. Many big applications like "whatsapp", use this database to store data on user's device.
The plus point of using "Sqlite" is that, you can iterate through each and every data easily.

It is quick, easy to work and is also a good programming practice. It is also secure.

0
John Quasar On

I suggest using Firebase to store your data. Not only it is online and realtime, it can also work in offline mode and sync later. Because you're developing a gym app, why not give it an online or offline capability? I think users prefer it that way. You can check it at firebase.google.com

0
Sayan Sarkar On

While using a sqlite database for managing your app data is the traditional approach, there are also alternatives to it. Realm is such an alternative. You can check the comparison with sqlite and see if it meets your need. https://realm.io/

0
Tulsi On

In Android development, you can store locally and as well as remotely. This link will walk you through all possible ways to store data.

As per your requirement, I would recommend you got for SQLite Database provided especially for android as it is light weight. Sqlite queries are straightforward and easy to use with some APIs comes with the package. you can start with this link with Sqlite.