I want to get some data from my database I have created using my application. Here is my code
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.select_to_delete);
database = new DatabaseHandler(this);
bundle = getIntent().getExtras();
date = bundle.getString("DATE");
SQLiteDatabase db=database.getWritableDatabase();
Cursor cur=db.rawQuery("SELECT " +TITLE+ " FROM " +TABLE_NAME + " WHERE " + CDATE + "=" + date,null);
int i = cur.getCount();
if(cur !=null){
if (cur.moveToFirst()){
do{
tdate = cur.getString(cur.getColumnIndex("DATE"));
titlearray.add(tdate);
}while(cur.moveToNext());
}
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, titlearray);
ListView listView = (ListView) findViewById(R.id.listView1);
listView.setAdapter(adapter);
}
My table has 5 columns (id, title, date, time, descrption). and have 4 raws. The table is created in another class.
When I run this application it doesn't get the data from the sql table and show it in listview. When I debug it, it shows i=1
and the it returns false to if (cur.moveToFirst())
. So it doesn't go inside that if
part.
What could my mistake be?