Thursday, December 29, 2011

[android-developers] How should one delete all of the table(but not the table itself) without making the thread using that database give an error?

So I'm trying to have a menu button to clear my database when it is
pressed, that works fine. However, as soon as new information is sent
to the database the app force closes. How should i stop this? Here is
the clear part:

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
case INSERT_ID:
//reset just makes all the variables in the thred reinitialize at base
values
mLemonadeMainMenuView.reset();
NotesMade = 0;
mDbHelper.deleteAllNotes();
return true;
}

Here is the new data information:

@Override
public boolean onTouchEvent(MotionEvent event) {
mDbHelper.createNote(event.getX(), event.getY(), 1);
NotesMade ++;
mLemonadeMainMenuView.setCoords(NotesMade);
return true;
}
Finally, here is the recieving end:

while(mNotesMade>mNoteId)
{mNoteId++;
Cursor note = mDbHelper.fetchNote(mNoteId);
Float x;
Float y;
Float size;
x =
Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_X)));
y=
Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_Y)));
size
=Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_X)));
canvas.drawCircle(x, y, 1, paint);}
}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment