public void readDb() { dbHelper = DatabaseHelper.getInstance(getActivity()); db = dbHelper.getReadableDatabase(); cursor = db.query("tbl_remittances", null, null, null, null, null, null); // populate here using while loop if (cursor != null) { while (cursor.moveToNext()) { rId = cursor.getInt(0); rDate = cursor.getString(1); rType = cursor.getString(2); rMessage = cursor.getString(3); item.add(0, new RemittanceItem(rId, rDate, rType, rMessage)); } } adapter.notifyDataSetChanged(); }
public void addNewRemittance() { db = dbHelper.getWritableDatabase(); ContentValues values; values = new ContentValues(); values.put("rem_date", txtDate.getText().toString()); values.put("rem_title", txtTitle.getText().toString()); values.put("rem_message", txtMessage.getText().toString()); db.insert("tbl_remittances", null, values); db.close(); item.clear(); readDb(); }