۱۳۹۳/۰۹/۲۲, ۰۲:۱۰ ب.ظ
با توجه به راهنمایی های شما کدها به موارد زیر تغییر کردند و به درستی اجرا میشوند ولی هنوز فقط آخرین گزینه در دیتابیس داخل لیست ویو نمایش داده میشه. نمیدونم چطوری در notes همگی رو ذخیره کنم. اگر نوعش بکنم آرایه خطا میگیره.
کد پیاچپی:
//Create or Open DB
final SQLiteDatabase db = openOrCreateDatabase("add_note_db", Context.MODE_PRIVATE, null);
Cursor cursor = db.rawQuery("SELECT * FROM add_note_table WHERE fid = '"+ id +"'", null);
ArrayList<String> notes = null;
if (cursor.moveToFirst()) {
do {
String note = cursor.getString(cursor.getColumnIndex("note"));
Log.d("Show Notes: ", note);
notes = new ArrayList<String>(Arrays.asList(note));
} while (cursor.moveToNext());
}else {
tvsn.setText("Id " + id + " has no note");
}
db.close();
ListView lvShowNotes = (ListView) findViewById(R.id.listViewShowNotes);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(ShowNotes.this
,android.R.layout.simple_list_item_1, notes);
lvShowNotes.setAdapter(adapter);