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 1033581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:15:11+00:00 2026-05-16T14:15:11+00:00

Been trying to get an answer on what I am doing wrong all over

  • 0

Been trying to get an answer on what I am doing wrong all over the place. I would like the user to select a button in the calling class, open a called listactivity which displays the contents of a database, let the user click an entry, copy that entry into a new database, send back the rowid from the new database to the calling class and have the calling class assign the title from the new database entry to the original button that was pushed.

Here is the calling class

static final private int CHOOSE_MONDAY = 0; 
static final private int CHOOSE_TUESDAY = 0;
 private int ButtonPushed = 0; 
private NotesDbAdapter mDbHelper; 
private MenuDbAdapter menuDbHelper; 
private Long mRowId;
 String menuTitle; 
String menuProtein; 
String menuBody;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setContentView(R.layout.plan_menu);

    Toast.makeText(this, "Choose a day to pick a meal for!", Toast.LENGTH_LONG).show();
    mDbHelper = new NotesDbAdapter(this);
    mDbHelper.open();
    menuDbHelper = new MenuDbAdapter(this);
    menuDbHelper.open();



}

public void mButtonHandler(View target)
{
    switch(target.getId())
    {
    case R.id.monday:
        // Create new intent object and tell it to call the ColorPicker class
        Intent question = new Intent(this, PlanMenuList.class); 
        // Start ColorPicker as a new activity and wait for the result 
        startActivityForResult(question, CHOOSE_MONDAY);
        break;
    case R.id.tuesday:
        // Create new intent object and tell it to call the ColorPicker class
        Intent question1 = new Intent(this, PlanMenuList.class);    
        // Start ColorPicker as a new activity and wait for the result 
        startActivityForResult(question1, CHOOSE_TUESDAY);
        break;
    }

And then this is the called class where I am trying to copy in the user’s selection to the new database and then send back the id to the calling class.

public class PlanMenuList extends ListActivity {

private NotesDbAdapter mDbHelper;
private MenuDbAdapter menuDbHelper;
private List<Data>data;
String menuTitle;
String menuProtein;
String menuBody;
private Long mRowId;




/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.notes_list);
    mDbHelper = new NotesDbAdapter(this);
    menuDbHelper = new MenuDbAdapter(this);
    mDbHelper.open();
    menuDbHelper.open();
    fillData(); 
}

private void fillData() {
    Cursor notesCursor = mDbHelper.fetchAllNotes();
    startManagingCursor(notesCursor);

    // 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, notesCursor, from, to);
    setListAdapter(notes);

}

private void populateFields() {
    if (mRowId != null) {
        Cursor note = mDbHelper.fetchNote(mRowId);
        startManagingCursor(note);
        menuTitle=(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
        menuProtein=(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_PROTEIN)));
        menuBody=(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
}





protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    mDbHelper.fetchNote(id);
    mRowId = id;
    //populateFields();
    menuDbHelper.createMenu("Monday", menuTitle, menuProtein, menuBody);
    Intent answer = new Intent();
    answer.putExtra("MenuDbAdapter.KEY_ROWID", mRowId);
    setResult(RESULT_OK, answer);
    finish();



}
}

I have been messing around with this thing for days and can’t seem to get it to do what I want – any help would be appreciated.

  • 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-16T14:15:12+00:00Added an answer on May 16, 2026 at 2:15 pm

    Can you post your onActivityResult implementation?
    When I’ve passed data back to an activity as a result, I’ve used Bundles. For example:

    Intent answer = new Intent();
    Bundle extras = new Bundle();
    extras.putLong("MenuDbAdapter.KEY_ROWID", mRowId);
    answer.putExtras(extras);
    

    Then, in the activity result handler, you’d call Intent.getExtras and pull your value from there.

    Edit: here are some examples from the android dev guide:
    http://developer.android.com/guide/appendix/faq/commontasks.html (search for onActivityResult)
    http://developer.android.com/resources/tutorials/notepad/notepad-ex3.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.