i am trying to create a user for my application. but after taking the
appropriate details when i press the confirm button my program
crashes. can anybody tell me what is the problem???

here is the code for that activity:-

package kumar.avinash.pbi.learnoid;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

@SuppressWarnings("unused")
public class EditUser extends Activity {
        private static EditText mEditUserId;
        private static EditText mEditUserPass;
        private static Long mRowId;
        private static LearnoidDbAdapter mDbHelper;
        private static String user_id;
        private static String pass;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                mDbHelper = new LearnoidDbAdapter(this);
                mDbHelper.open();
                if (mRowId == null) {
                        Bundle extras = getIntent().getExtras();
                        mRowId = (extras != null) ?
extras.getLong(LearnoidDbAdapter.KEY_ROWID) :
                                null;
                }

                setContentView(R.layout.user_edit);
                setTitle("create user");

                mEditUserId = (EditText) findViewById(R.id.user_id);
                user_id = mEditUserId.toString();
                mEditUserPass = (EditText) findViewById(R.id.pass);
                pass = mEditUserPass.toString();

                Button confirmButton = (Button) findViewById(R.id.confirm);
                mRowId = (savedInstanceState == null) ? null :
                        (Long)
savedInstanceState.getSerializable(LearnoidDbAdapter.KEY_ROWID);

                populateFields();

                confirmButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {

                setResult(RESULT_OK);
                finish();
                Intent edit_to_login = new Intent(EditUser.this,
Login.class);
                startActivity(edit_to_login);
               }

        });


                }

        private void populateFields() {
                if (mRowId != null) {
                        Cursor user = mDbHelper.fetchUser(mRowId);
                        startManagingCursor(user);
                        mDbHelper.createUser(user_id, pass);
                }
        }

        @Override
        protected void onPause() {

                super.onPause();
                saveState();
        }
        @Override
        protected void onResume() {

                super.onResume();
                //populateFields();
        }
        @Override
        protected void onSaveInstanceState(Bundle outState) {

                super.onSaveInstanceState(outState);
                saveState();
                outState.putSerializable(LearnoidDbAdapter.KEY_ROWID, mRowId);
        }

        private void saveState() {
                String user_id = mEditUserId.getText().toString();
                String user_pass = mEditUserPass.getText().toString();

                if (mRowId == null) {
                        long id = mDbHelper.createUser(user_id, user_pass);
                        if (id > 0) {
                                mRowId = id;
                        }
                } else {
                        mDbHelper.updateUser(mRowId, user_id, user_pass);
                }
        }

}

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to