So I have a class named A:
public class A{
private String A1;
private String A2;
private String A3;
private String A4;
private B A5;
private B A6;
}
That as you can see contains some strings and 2 B class typed object. The B class:
public class B{
private ArrayList<C> B1;
}
Contains 1 arraylist of C elements. The C class:
public class C{
private String C1;
private ArrayList<D> C2;
A string and arraylist of D objects. The D class:
public class D{
private String D1;
private Boolean D2;
}
I get the data from JSON files, I build up an arraylist out of A objects, but I should store it in a database because I do not want to download the data every time the user opens the application...
You are attempting to store non-atomic values into a relational database. You must normalize it using multiple tables which relate to each other using foreign keys. Quite a tedious task to do.
Perhaps you can store the object itself using serialization - resource
You just want to store the custom model object into a database so for this you can use room Persistence database by Google. Check the following link: local database using Roome
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.