-
Notifications
You must be signed in to change notification settings - Fork 64
Fake Data Layer
Manish Kumar edited this page Aug 6, 2018
·
3 revisions
Currently, this App doesn't consume any real APIs so to mock the server side response we are using a Fake data layer. A fake data layer is basically a dummy JSON response with the same data model and valid data as required in the App. To generate the fake JSON follow the following steps -
- Structure your data model write getter/setters for each variable
(Remember to add the POJO class of any custom data type you are using inside this data model, also enums if you are using them)
- Generate JSON using this
- Copy the generated JSON into a file name
{fileName}.json
and save into resources directory. You can easily locate resource directory from Android studio or else it is present underapp/src/main/resources
- To know how to further use the saved JSON as a server response and to develop a feature check this
There is a second way of adding fake date layer in the App. We are using DBFlow as our local database. For generating the response from the database follow the following step-
- Add the similar data model mentioned above in form of tables. For more guidelines on how to make tables and model follow this.
- After saving the data you can query/fetch the data from the database.
(Note: Use Stetho for database debugging purpose.)