I have following code & want all the data in arraylist comes from sqlite database
import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList; import java.util.HashMap;
public class DataSingleton extends Activity {
SQLiteDatabase db;
public ArrayList array;
private static DataSingleton dataSingleton;
public static DataSingleton getInstance() {
if (dataSingleton == null) {
dataSingleton = new DataSingleton();
}
return dataSingleton;
}
public ArrayList<String> visibleSections;
public HashMap<String, ArrayList<DataModel>> getDataList() {
HashMap<String, ArrayList<DataModel>> dataList = new HashMap<>();
ArrayList<DataModel> dataModelListWhoWeAre = new ArrayList<>();
for (int i = 1; i <= 1; i++) {
dataModelListWhoWeAre.add(new DataModel("About project Nanhikali ", R.drawable.abtprojectnanhikali));
dataModelListWhoWeAre.add(new DataModel("Why support project NanhiKali ", R.drawable.whysupportnanhikali));
dataModelListWhoWeAre.add(new DataModel("Managing Partner ", R.drawable.managingpartner));
dataModelListWhoWeAre.add(new DataModel("Implementing NGO partners ", R.drawable.anandmahindrainthenews));
dataModelListWhoWeAre.add(new DataModel("Our Supporters ", R.drawable.newsletter));
dataModelListWhoWeAre.add(new DataModel("our Team ", R.drawable.annualreport));
dataModelListWhoWeAre.add(new DataModel("Milestones ", R.drawable.successstories1));
dataModelListWhoWeAre.add(new DataModel("Project Nanhikali in USA ", R.drawable.sponsoragirl));
dataModelListWhoWeAre.add(new DataModel("Project Nanhikali in UK ", R.drawable.sponsoragirluk));
dataModelListWhoWeAre.add(new DataModel("Annual Reports ", R.drawable.testimonials));
dataModelListWhoWeAre.add(new DataModel("Newsletter ", R.drawable.initiative));
dataModelListWhoWeAre.add(new DataModel("Trustees ", R.drawable.managingpartner));
}
dataList.put("Who We Are", dataModelListWhoWeAre);
ArrayList<DataModel> dataModelProjectDo = new ArrayList<>();
for (int i = 1; i <= 1; i++) {
dataModelProjectDo.add(new DataModel("Initiatives & Activities ", R.drawable.initiative));
dataModelProjectDo.add(new DataModel("Reach", R.drawable.reach));
dataModelProjectDo.add(new DataModel("Success Stories ", R.drawable.successstories1));
dataModelProjectDo.add(new DataModel("Testimonials ", R.drawable.testimonials));
dataModelProjectDo.add(new DataModel("Donate ", R.drawable.sponsoragirl));
}
dataList.put("What We Do", dataModelProjectDo);
ArrayList<DataModel> dataModelProjectHelp = new ArrayList<>();
for (int i = 1; i <= 1; i++) {
dataModelProjectHelp.add(new DataModel("Get Involved ", R.drawable.sponsoragirluk));
dataModelProjectHelp.add(new DataModel("Corporate Social Responsibility ", R.drawable.sponsoragirluk));
dataModelProjectHelp.add(new DataModel("Donate ", R.drawable.sponsoragirluk));
}
dataList.put("How Can You Help", dataModelProjectHelp);
ArrayList<DataModel> dataModelProjectLook = new ArrayList<>();
for (int i = 1; i <= 1; i++) {
dataModelProjectLook.add(new DataModel("Photo gallery ", R.drawable.sponsoragirl));
dataModelProjectLook.add(new DataModel("Video Gallery ", R.drawable.sponsoragirluk));
dataModelProjectLook.add(new DataModel("Wallpapers ", R.drawable.abtprojectnanhikali));
dataModelProjectLook.add(new DataModel("Posters ", R.drawable.successstories1));
}
dataList.put("Take a Look", dataModelProjectLook);
ArrayList<DataModel> dataModelProjectNews = new ArrayList<>();
for (int i = 1; i <= 1; i++) {
dataModelProjectNews.add(new DataModel("News & Events ", R.drawable.sponsoragirluk));
dataModelProjectNews.add(new DataModel("News ", R.drawable.sponsoragirluk));
dataModelProjectNews.add(new DataModel("Events ", R.drawable.sponsoragirluk));
}
dataList.put("In The News", dataModelProjectNews);
ArrayList<DataModel> dataModelProjectTouch = new ArrayList<>();
for (int i = 1; i <= 1; i++) {
dataModelProjectTouch.add(new DataModel("facebook ", R.drawable.sponsoragirl));
dataModelProjectTouch.add(new DataModel("Twitter ", R.drawable.sponsoragirluk));
dataModelProjectTouch.add(new DataModel("Linkedln ", R.drawable.sponsoragirl));
dataModelProjectTouch.add(new DataModel("Whatsapp ", R.drawable.sponsoragirluk));
}
dataList.put("Get In Touch", dataModelProjectTouch);
return dataList;
}
public ArrayList<String> getSectionTitles() {
return array;
}
public DataSingleton() {
visibleSections = new ArrayList<>();
visibleSections.add("Who We Are");
visibleSections.add("What We Do");
visibleSections.add("How Can You Help");
visibleSections.add("Take a Look");
visibleSections.add("In The News");
visibleSections.add("Get In Touch");
}
}
Aucun commentaire:
Enregistrer un commentaire