Studying a variety of development resources on the platform, the Android encountered the use of MVC architecture. As I correctly understood, this is Model.View.Controller where Model is, roughly speaking, that part of the program (in the form of code or something else) that implements data storage in the application. Actually the question itself is which way to choose? Considering that the development for the android platform, for the most part is carried out using the java language, several methods are recalled - such as properties, preferences, some kind of encrypted data type, like p12, databases - SQLite. So what is the best way and what should affect the choice of a particular method?
1 answer
In general, the model in the MVC pattern can be not only all sorts of data types, but also “bare” business logic. The model here is what should be displayed on the screen, View - as displayed and the controller - how it interacts with the world
As for the data itself, a lot depends on the data itself: their type, method of obtaining, the place of initial storage, the tasks to be solved and the individual preferences of the developer (experience and education) and here there can be no one-to-one right answer. To solve one problem, one option would be appropriate, but for another, the same option is not at all acceptable.
The main data sources in Android are primarily SQLite databases and the following are files with some kind of structure - JSON, XML, and so on.
Preferences are not intended to store data at all - their use is the preservation of the state of tinctures and other such "flags".
For myself, I chose ORM Realm for the following reasons:
- Representation and storage of data in the form of a classical POJO model
- No SQLLite add-in. Own engine written in C ++
- Speed
- Developed API, which is constantly updated and clear syntax.
- A model can contain arbitrary methods with logic, and not just getters / field setters
- After receiving a sample of the database on request and making changes to it, these changes are entered immediately into the database. No separate logic required to save changes
- A wide range of applications, as it can be used not only as a database (filters, samples, bindings, etc.), but also as a simple repository of unstructured information.
Disadvantages:
- The beta version, respectively, of some tools that are familiar to the operation of the DBMS in general and SQLite in particular, has not yet been implemented.