Search code examples
javaandroidsaving-data

Where to place my android app's data


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!


Solution

  • 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.