I am very novice programmer in Android. My query is to fetch data from SQLite and then reflect all data in to list column . now when i click on button, that all data must be converted in .pdf format with good tabularised format... Millions of thank in advance..
public class Details_List extends Activity {
Button share;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.details_list);
ListView lv= (ListView)findViewById(R.id.listview);
share = (Button)findViewById(R.id.email);
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Details_List.this, Email.class);
startActivity(i);
}
});
// create the grid item mapping
String[] from = new String[] {"rowid", "col_1", "col_2", "col_3", "col_4", "col_5"};
int[] to = new int[] { R.id.item1, R.id.item2, R.id.item3, R.id.item4, R.id.item5, R.id.item6};
// prepare the list of all records
List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
for(int i = 1; i < 10; i++){
HashMap<String, String> map = new HashMap<String, String>();
map.put("rowid", "" + i);
map.put("col_1", "col_1_item_" + i);
map.put("col_2", "col_2_item_" + i);
map.put("col_3", "col_3_item_" + i);
map.put("col_3", "col_4_item_" + i);
map.put("col_3", "col_5_item_" + i);
fillMaps.add(map);
}
// fill in the grid_item layout
SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.grid_item, from, to);
lv.setAdapter(adapter);
}
}
for your first purpose to get data from SQLite DB into arraylist, here is an example below:
and this is the entity class:
to get all data from SQLite in arraylist write below code in your activity:
I hope this helps you...