I\'ll use RecyclerView for a section header
I want to create section header when i insert each Date & Time data in SQLite Database
I followed
here is a sample Json for you all you have to do is save save and fetch your data in this way, run this sample on Json viewer and see structure.!
for SQLIte
public static final String TABLE_NAME = "companies_dates";
public static final String COLUMN_TIMESTAMP = "timestamp"; //primary key
public static final String COLUMN_ID = "id";// primary key
public static final String TABLE_NAME = "companies";
public static final String COLUMN_ID = "id";// primary key
public static final String COLUMN_ID_PARENT = "id_parent"; //foreign key //primary key form table companies_dates
//or use date as parent_date
public static final String COLUMN_DATE_PARENT = "timestamp";
public static final String COLUMN_TITLE = "company";
public static final String COLUMN_TIMESTAMP = "timestamp";
// ResponseMain.Java
public class CompaniesResponse{
ArrayList companiesList;
public ArrayList getCompaniesList() {
return companiesList;
}
public void setCompaniesList(ArrayList companiesList) {
this.companiesList = companiesList;
}
}
public class Companies{
private String timeStamp;
ArrayList companiesArrayList;
public String getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(String timeStamp) {
this.timeStamp = timeStamp;
}
public ArrayList getCompaniesArrayList() {
return companiesArrayList;
}
public void setCompaniesArrayList(ArrayList companiesArrayList) {
this.companiesArrayList = companiesArrayList;
}
}
public class CompaniesItem{
private String title;
private String id;
private String timeStamp;
private String parentId;
private String parentTimeStamp;
//getter setters
}
@Override
public void onCreate(Bundle savedInstanceState) {
//super.onCreate(savedInstanceState);
CompaniesResponse companiesResponse = new CompaniesResponse();
Companies companies = new Companies();
// CompaniesItem companiesItem = new CompaniesItem();
//companiesItem.setId("1");
// companiesItem.setTimeStamp("Time Stamp");
// ArrayList companiesItemArrayList = new ArrayList<>();
// companiesItemArrayList.add(companiesItem);
companiesItemArrayList.add(myDb.getAllCompany());
companies.setTimeStamp(myDb.getDate());
companies.setCompaniesArrayList(companiesItemArrayList);
ArrayList companieslist = new ArrayList<>();
companieslist.add(companies);
companiesResponse.setCompaniesList(companieslist);
}
for Json
{
"companies ": [
{
"date": "12-08.2018",
"companiesList": [
{
"title": "Atmel Corporation",
"date": "11/11/2017 3:46 PM"
},
{
"title": "Ketul Inc.",
"date": "11/11/2017 3:46 PM"
}
]
},
{
"date": "09/19/2017 8:46 PM",
"companiesList": [
{
"title": "Huron Capital Partners LLC",
"date": "15-06-2018"
},
{
"title": "ABC Technologies",
"date": "09/12/2017 7:41 PM"
}
]
}
]
}