tags:

views:

70

answers:

1

Hi am creating a small application In View Page am doing update and delete operation from database am displaying data s in the top (ex 10 records) and bottom i have 2 buttons Edit and delete if user clicks Edit button it redirects to Edit page In Edit page i am displaying content for editing also i have 2 buttons update and cancel if user click update again am redirecting(using start activity) to view page It is not displaying new records. i went back to main page and then i clicked view page now it is updated How to solve this ??? Another problem is At the same if user clicks back button it is going all page which i went (through redirected page)

For example First i clicked view page from main page in view page am doing edit and delete operation after completing this it goes to view page Here i am clicking back button it is going previous page that is edit or delete page which i have performed last I need to go main page from view (after performing edit or delete op) How to do this ?

Please Help me Thanks in Advance

A: 

For your problem with the user editing data and the results are not being displayed make sure you are populating it with your new data. See this for more info.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    mDbHelper = new NotesDbAdapter(this);
    mDbHelper.open();

    setContentView(R.layout.note_edit);

    mTitleText = (EditText) findViewById(R.id.title);
    mBodyText = (EditText) findViewById(R.id.body);

    Button confirmButton = (Button) findViewById(R.id.confirm);

    mRowId = savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null;
    if (mRowId == null) {
        Bundle extras = getIntent().getExtras();
        mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null;
}

private void populateFields() {
    if (mRowId != null) {
        Cursor note = mDbHelper.fetchNote(mRowId);
        startManagingCursor(note);
        mTitleText.setText(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
        mBodyText.setText(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
}
David Glass