When I tried this as

try
                {
                        sampleDB =  this.openOrCreateDatabase(SAMPLE_DBNAME,
MODE_PRIVATE, null);
                        Cursor c = sampleDB.rawQuery("SELECT RoomID as _id FROM 
"
+ROOM_TABLE_NAME, null);
                        System.out.println ("Total number of rooms
are"+c.getCount());


                          adapter = new SimpleCursorAdapter(
                          this,
                          R.layout.roomlist,
                          c,
                          new String[] {"RoomID"},
                          new int[] {R.id.roomname});
          roomList.setAdapter(adapter);

                }
                 catch (Exception e)
                 {
                         e.printStackTrace();
                 }

then it throws following exception

12-03 13:32:25.331: INFO/System.out(902): Total number of rooms are1
12-03 13:32:25.340: WARN/System.err(902):
java.lang.IllegalArgumentException: column 'RoomID' does not exist
12-03 13:32:25.370: WARN/System.err(902):     at
android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:
314)
12-03 13:32:25.370: WARN/System.err(902):     at
android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:
339)
12-03 13:32:25.389: WARN/System.err(902):     at
android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:91)
12-03 13:32:25.400: WARN/System.err(902):     at
com.monarch.home.RemoveRoom.displayRoomList(RemoveRoom.java:47)
12-03 13:32:25.414: WARN/System.err(902):     at
com.monarch.home.RemoveRoom.onCreate(RemoveRoom.java:29)
12-03 13:32:25.451: WARN/System.err(902):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
12-03 13:32:25.451: WARN/System.err(902):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2459)
12-03 13:32:25.470: WARN/System.err(902):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2512)
12-03 13:32:25.492: WARN/System.err(902):     at
android.app.ActivityThread.access$2200(ActivityThread.java:119)
12-03 13:32:25.519: WARN/System.err(902):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
12-03 13:32:25.519: WARN/System.err(902):     at
android.os.Handler.dispatchMessage(Handler.java:99)
12-03 13:32:25.531: WARN/System.err(902):     at
android.os.Looper.loop(Looper.java:123)
12-03 13:32:25.550: WARN/System.err(902):     at
android.app.ActivityThread.main(ActivityThread.java:4363)
12-03 13:32:25.550: WARN/System.err(902):     at
java.lang.reflect.Method.invokeNative(Native Method)
12-03 13:32:25.550: WARN/System.err(902):     at
java.lang.reflect.Method.invoke(Method.java:521)
12-03 13:32:25.560: WARN/System.err(902):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-03 13:32:25.560: WARN/System.err(902):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-03 13:32:25.570: WARN/System.err(902):     at
dalvik.system.NativeStart.main(Native Method)



On Dec 3, 12:51 pm, "Jonas Petersson" <[email protected]> wrote:
> Um, you might try something like "select RoomID as _id ..."
>
>                         Best / Jonas
>
> On 12/03/2010 08:40 AM, Kumar Bibek wrote:
>
> > You cannot in this case. This is a mandatory requirement.
>
> > "pramod.deore"<[email protected]>  wrote:
>
> >> Hi Bibek, Thanks for reply. But my table RoomTable have only three
> >> columns, RoomID, RoomName, and RoomSuffix. It doesn't have  _id field.
> >> Then how to use Cursor Adapter here.
>
> >> On Dec 3, 11:55 am, Kumar Bibek<[email protected]>  wrote:
> >>> Cursor Adapters require the table to have a _id field. Else, you would get
> >>> this exception.
> >>> Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to