Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6669027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:06:14+00:00 2026-05-26T03:06:14+00:00

Here i am trying to pass my RowId to another activity, but it is

  • 0

Here i am trying to pass my RowId to another activity, but it is printing null.In my myprofile class i am trying to pass the row id. Please any one help me.

myprofile class

public class MyProfile extends Activity implements OnClickListener 
{

private MyProfileDb mDbHelper;

private TextView mAllergiesText;
private TextView mConditionsText;
private TextView mBloodText;
private TextView mNoteText;
private long mRowId ;


@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myprofile);

    mDbHelper = new MyProfileDb(this);
    mDbHelper.open();

    View home = findViewById(R.id.home);
    home.setOnClickListener(this);

    View add = findViewById(R.id.add);
    add.setOnClickListener(this);

    mAllergiesText = (TextView) findViewById(R.id.allergy);
    mConditionsText = (TextView) findViewById(R.id.condition1);
    mBloodText = (TextView) findViewById(R.id.blood1);
    mNoteText = (TextView) findViewById(R.id.note);



    Cursor c = mDbHelper.fetchAlldetails();

    if (c.getCount() >= 1) 
    {

        populateFields(c.getCount());
        c.close();
    } 

}

public void onClick(View v) 
{    
    switch (v.getId()) 
    {    
    case R.id.home:
        mDbHelper.close();
        Intent homeActivity = new Intent(this, Menu.class);
        startActivity(homeActivity);
        finish();
        break;

    case R.id.add:  
        Intent addActivity = new Intent(this, EditMyProfile.class);  
         addActivity.putExtra("id",   String.valueOf(mRowId)); 
          System.out.println("id is"+ mRowId);

        startActivity(addActivity);

        mDbHelper.close();
        break;
    }
}

private void populateFields(int mRowId)
{ 
    Cursor profile = mDbHelper.fetchdetails(mRowId);
    startManagingCursor(profile);

    mAllergiesText.setText(profile.getString(profile
            .getColumnIndexOrThrow(MyProfileDb.KEY_ALLERGIES)));
    mConditionsText.setText(profile.getString(profile
            .getColumnIndexOrThrow(MyProfileDb.KEY_CONDITIONS)));
    mBloodText.setText(profile.getString(profile
            .getColumnIndexOrThrow(MyProfileDb.KEY_BLOOD)));
    mNoteText.setText(profile.getString(profile
            .getColumnIndexOrThrow(MyProfileDb.KEY_NOTE))); 

    profile.close();
}

@Override
public final boolean onKeyDown(int keyCode, KeyEvent event) {

    if (KeyEvent.KEYCODE_BACK == keyCode) {
        startActivity(new Intent(this, Menu.class));
        onDestroy();
    }
    return super.onKeyDown(keyCode, event);

}

}

editmyprofile class

public class EditMyProfile extends Activity implements OnClickListener {


private EditText mAllergiesText;
private EditText mConditionsText;
private EditText mBloodText;
private EditText mNoteText;

private Long mRowId;
private MyProfileDb mDbHelper;
private int i;
//private Long id;



@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.editmyprofile);

    mDbHelper = new MyProfileDb(this);
    mDbHelper.open();

    View profilecancel = findViewById(R.id.profilecancel);
    profilecancel.setOnClickListener(this);

    mAllergiesText = (EditText) findViewById(R.id.allergies);
    mConditionsText = (EditText) findViewById(R.id.condition);
    mBloodText = (EditText) findViewById(R.id.blood);
    mNoteText = (EditText) findViewById(R.id.note);

    View save = findViewById(R.id.profilesave);
    save.setOnClickListener(this);

    View doccancel = findViewById(R.id.profilecancel);
    doccancel.setOnClickListener(this);

    View homeText = findViewById(R.id.homeInEditProfile);
    homeText.setOnClickListener(this);

    View home  = findViewById(R.id.home );
    home.setOnClickListener(this); 

    mRowId = Long.parseLong(getIntent().getStringExtra("id"));

    mRowId = (savedInstanceState==null) ? null:
        (Long)savedInstanceState.getSerializable(MyProfileDb.KEY_ROWID);
    if(mRowId == null)
    {
        Bundle Extras = getIntent().getExtras();
        mRowId = Extras != null ? Extras.getLong(MyProfileDb.KEY_ROWID): null;
    }

}

public void onClick(View v) {
    switch (v.getId()) {
    case R.id.profilecancel:
        mDbHelper.close(); 
        startActivity(new Intent(this, MyProfile.class));
        finish();
        break;

    case R.id.profilesave: 
        saveState(); 
        mDbHelper.close(); 
        startActivity(new Intent(this, MyProfile.class));
        break;

    case R.id.homeInEditProfile:
    case R.id.home:
        mDbHelper.close(); 
        startActivity(new Intent(this, Menu.class));
        break;
    }
}

private void saveState() 
{
    String allergies = mAllergiesText.getText().toString();
    String conditions = mConditionsText.getText().toString();
    String bloodgroup = mBloodText.getText().toString();
    String note = mNoteText.getText().toString();     


     if (mRowId == null) 
    {
        System.out.println("ROW"+ mRowId);
        long id = mDbHelper.createdetails(allergies, conditions, bloodgroup, note);
        if (id > 0) 
        {
            System.out.println("ROW"+ id);
            mRowId = id;

        }

    } 
    else 
    {
        mDbHelper.updatedetails(mRowId, allergies, conditions, bloodgroup, note);
    } 
}

@Override
public final boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    if (KeyEvent.KEYCODE_BACK == keyCode)
    {
        startActivity(new Intent(this, Menu.class));
        finish();
        onDestroy();
    }
    return super.onKeyDown(keyCode, event);

}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:06:15+00:00Added an answer on May 26, 2026 at 3:06 am

    Hi sachi Please try the below code .

    private void populateFields(int mRowId)
    { 
        this.mRowId = mRowId;
        Cursor profile = mDbHelper.fetchdetails(mRowId);
        startManagingCursor(profile);
    
        mAllergiesText.setText(profile.getString(profile
                .getColumnIndexOrThrow(MyProfileDb.KEY_ALLERGIES)));
        mConditionsText.setText(profile.getString(profile
                .getColumnIndexOrThrow(MyProfileDb.KEY_CONDITIONS)));
        mBloodText.setText(profile.getString(profile
                .getColumnIndexOrThrow(MyProfileDb.KEY_BLOOD)));
        mNoteText.setText(profile.getString(profile
                .getColumnIndexOrThrow(MyProfileDb.KEY_NOTE))); 
    
        profile.close();
    }
    

    Or

    you can try this.

    if (c.getCount() >= 1) 
        {
            this.mRowId = c.getCount();
            populateFields(c.getCount());
            c.close();
        } 
    else
    {
         this.mRowId = 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass a list from one form class to another. Here's the
I am trying to pass custom event data from 1 class to another class...here
I am trying to pass an arrayList to another activity using intents. Here is
I'm trying to pass the boost::geometry::get function described here to another function, but I
i am trying to pass an arraylist back to my parent activity Here is
My terminology is probably way off here but basically I'm trying to pass multiple
Perhaps I'm being too ambitious here, but I'm trying to pass a shared_ptr back
I am trying to pass a value from one tab to another. I tried
I'm trying to pass one method to another in elisp, and then have that
hi im trying to pass some values to a class but it wont let

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.