Hello, a bit more data on the problem of "_id" column not existing,
a post that I had made earlier.
Inside of my query in a ContentProvider I attempt to read the
database. The error points back to the "_id" no such column. I don't
get it? I have tried upper case and lowercase "_id" name. the column
is there as you can see in the Log output.
I am still working on it but??
thanks
Jeff
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + MEDS_TABLE_NAME + " ("
+ Meds._ID + " INTEGER PRIMARY KEY autoincrement,"
+ Meds.sMEDS_FK + " INTEGER ,"
+ Meds.sSTATUS + " TEXT,"
+ Meds.sSOURCE + " TEXT,"
+ Meds.sPRODUCT + " TEXT,"
+ Meds.sDIRECTIONS + " TEXT,"
+ Meds.sFULLFILLHISTORY + " TEXT,"
+ Meds.sCREATION_DATE + " TEXT,"
+ Meds.sMODIFIED_DATE + " TEXT"
+ ");");
Log.w(TAG, "onCreate");
}
<b>Insert is working:</b>
long rowId = db.insert(MEDS_TABLE_NAME, Meds.MED, values);
Log.e(TAG, "aft insert rowId = " + rowId);
LOG --11-21 08:32:30.983: ERROR/MPhrProvider(195): aft insert rowId =
10
if (rowId > 0) {
Uri medUri = ContentUris.withAppendedId
(MPhrDef.Meds.CONTENT_URI, rowId); // append rowid at end of givin uri
getContext().getContentResolver().notifyChange(medUri,
null);
return medUri;
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor c = qb.query(db, projection, selection, selectionArgs,
null, null, null);
Log.e(TAG, "OnCreate cursor.getColumnName0 = " +
c.getColumnName(0));
Log.e(TAG, "OnCreate cursor.getColumnName1 = " +
c.getColumnName(1));
11-21 09:10:19.120: ERROR/MPhrProvider(195): OnCreate
cursor.getColumnName0 = _ID
11-21 09:10:23.240: ERROR/MPhrProvider(195): OnCreate
cursor.getColumnName1 = SOURCE
detailMessage "Invalid column _ID"
--------------
Here I changed the case of _ID to _id (lower)
Cursor c = qb.query(db, projection, selection, selectionArgs, null,
null, null);
Log.e(TAG, "OnCreate cursor.getColumnName0 = " +
c.getColumnName(0));
Log.e(TAG, "OnCreate cursor.getColumnName1 = " +
c.getColumnName(1));
LOGCAT
[0] "_id"
[1] "SOURCE"
String[] p = {"_id", "SOURCE", "PRODUCT"};
String st = qb.buildQuery(p, selection, selectionArgs, null,
null, orderBy, null);
Cursor cc =db.rawQuery(st, null);
11-21 09:28:57.376: ERROR/MPhrProvider(194): OnCreate
cursor.getColumnName0 = _ID
11-21 09:29:12.129: ERROR/MPhrProvider(194): OnCreate
cursor.getColumnName1 = SOURCE
com.sun.jdi.InvocationException occurred invoking method.
Unable to start activity ComponentInfo{com.csi.android.mPHR/
com.csi.android.mPHR.MPhrList}:
android.database.sqlite.SQLiteException: no such column: modified: ,
while compiling: SELECT _id, SOURCE, PRODUCT FROM medsTbl ORDER BY
modified DESC
Detail formatter error:
An exception occurred: android.database.sqlite.SQLiteException
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.csi.android.mPHR/com.csi.android.mPHR.MPhrList}:
android.database.sqlite.SQLiteException: no such column: modified: ,
while compiling: SELECT _id, SOURCE, PRODUCT FROM medsTbl ORDER BY
modified DESC
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---