In my simple java application i have this function to return ArrayList:
Items.java class:
package com.example.Hadis;
/**
* Created by tux-world on 8/1/14.
*/
public class Items {
public int id;
public String content;
}
ArrayList function for fill and return result:
DataBaseHelper.java class's getFavorite function :
public ArrayList<Items> getFavorite(){
ArrayList<Items> arrayList = new ArrayList<Items>();
do {
Items dbItems = new Items();
dbItems.id = cursor.getInt(0);
dbItems.content = cursor.getString(1);
arrayList.add(dbItems);
} while (cursor.moveToNext());
return arrayList;
}
i want to fetch this return ArrayList and fill HashMap but i can not program this part of project
Defined map as Method in class:
static Map<Integer,String> map = new HashMap<Integer,String>();
retrive ArrayList and my problem is this:
DatabaseHandler db = new DatabaseHandler(ApplicationHadith.this);
ArrayList<Items> list = db.getFavorite();
Iterator<Items> it = list.iterator();
while(it.hasNext())
{
// map.put( it.id , it.content )
}
how to retrive getFavorite() and fill HashMap? please help me.Thanks
getFavorite()and fillHashMapmap