thank you for reply! :-)
If I change the _id that is default field's name to other, the program
will throw an exception
It means that I must have a field named _id in the data table, is
right?
can I change the name of id field?

Ahmed Abdel samea wrote:
> I will tell you in the create new note the id field in database take th
> rowid in the listview as its id ok
>
> so when i delete all what i need is that id so i retrieve it from the
> listview as i said before the rowid is the id in the database
>
>
>
> Hope i have answered ur question
>
>
> Yours, --( H o H i )--
>
> --- On Mon, 5/12/08, alan Gold <[EMAIL PROTECTED]> wrote:
> From: alan Gold <[EMAIL PROTECTED]>
> Subject: [android-beginners] question on getSelectedItemId function
> To: android-beginners@googlegroups.com
> Date: Monday, May 12, 2008, 10:35 AM
>
> Hello All!
> I just do the exercise 2 in tutorial document, and I have a question in
> the onMenuItemSelected function.
>
> @Override
> public boolean onMenuItemSelected(int featureId, Item item) {
> switch(item.getId()) {
> case INSERT_ID:
> createNote();
> return true;
> case DELETE_ID:
> mDbHelper.deleteNote(getListView().getSelectedItemId());
> fillData();
> return true;
> }
>
> return super.onMenuItemSelected(featureId, item);
> }
>
> when I delete the note,the code will call getSelectedItemId() to get
> the id of the row. But I don't specify the the "id" field in
> fillData(). only the "text1" field was passed to the Constructor of
> SimpleCursorAdapter, how can the getSelectedItemId function to get the
> id?
> SimpleCursorAdapter will automatic add the id field? Somebody know why?
> Thanks!
>
> private void fillData() {
> // Get all of the rows from the database and create the item list
> mNotesCursor = mDbHelper.fetchAllNotes();
> startManagingCursor(mNotesCursor);
>
> // Create an array to specify the fields we want to display in the list
> (only TITLE)
> String[] from = new String[]{NotesDbAdapter.KEY_TITLE};
>
> // and an array of the fields we want to bind those fields to (in this
> case just text1)
> int[] to = new int[]{R.id.text1};
>
> // Now create a simple cursor adapter and set it to display
> SimpleCursorAdapter notes =
> new SimpleCursorAdapter(this, R.layout.notes_row, mNotesCursor, from,
> to);
> setListAdapter(notes);
> }
>
>
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
> it now.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to