It's been long fight between mysql and sql lite date issue. I have a complex query which returns multiple data.
I read server Json objects and store them in sql lite android was fine. So i did a query which is like below one
"SELECT * FROM " + MAIN_TABLE + " LEFT OUTER JOIN " + SERVICE_INFO_TABLE + " ON ServiceInfo.main_id = MAIN_TABLE._ID" + " LEFT OUTER JOIN " + M_USER_TABLE + " ON M._ID = ServiceInfo.m_id" + " LEFT OUTER JOIN " + U_TABLE + " ON MAIN_TABLE.u_id = U_TABLE._ID"
The problem starts when i read the MAIN_TABLE which contains creation_time and upation_time, The SERVICE_INFO_TABLE also contains creation_time, updation_time.
However the table contains different date and time respectively. The cursor returns same date and time for all entity.
It seems the cursor method got confused and return same data and time read from ServiceInfo table.
I dig deeper into debugging mode while SQL lite read the query, i saw strange things happening over there. Below is the reading example
Cursor cursor = sqLiteDatabase.rawQuery(selectQuery, null);
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
do {
Log.d("dummy", "dummy stopper");
VParcelable vParcelable = new VParcelable();
vParcelable.setId(cursor.getInt(cursor.getColumnIndex(VEntry._ID)));
vParcelable.setModel(cursor.getString(cursor.getColumnIndex(VEntry.MODEL)));
vParcelable.setYearMdl(cursor.getInt(cursor.getColumnIndex(VEntry.YEAR_MODEL)));
vParcelable.setCreationTime(cursor.getString(cursor.getColumnIndex(VEntry.CRE_TIME)));
vParcelable.setUpdationTime(cursor.getString(cursor.getColumnIndex(VEntry.UPA_TIME)));
So the ServiceInfo table also contains the same creation_time and updation_time.
vParcelable.setCreationTime(cursor.getString(cursor.getColumnIndex(VEntry.CRE_TIME)));
mColumns from cursor debugging mode shows "updation_time" and "creation_time" for VTable and same as for ServiceInfo table.
Is that problem of sql lite couldn't differentiate table column names?
That really sucks.
Help please.
Thanks