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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:50:38+00:00 2026-05-27T23:50:38+00:00

I have problem regarding passing the string array as extra in the bundle. I

  • 0

I have problem regarding passing the string array as extra in the bundle. I have written the following code to store the title, info and speaker when the moduleType = “v”. The code uses the bundle to put the array of strings in PopulateData activity and pass it to the next actvity i.e DataList Activity. My code is as follows:

PopulateData.java

for(int i = 0; i < moduleTypes.length; i++){
            String moduleType = moduleTypes[i];
            JSONObject jsonModule = new JSONObject(content[i]);
            //Bundle[] bundle = new Bundle[jsonModule.length()];
            Log.i(TAG, "ModuleType = v " + (moduleType == "v"));
            Log.i(TAG, "ModuleType = v " + moduleType.equals("v"));
            Log.i(TAG, "ModuleType =  " + moduleType);
            Log.i(TAG, "ModuleType Length =  " + moduleTypes.length);
            if(moduleType.equals("v")){
                //String[] title = new String[jsonModule.length()];
                //String[] info = new String[jsonModule.length()];
                //String[] speaker = new String[jsonModule.length()];
                String[] videoTypes = dbAdapter.collectVideoTypeFromListTable();
                String[] title = new String[videoTypes.length];
                String[] info = new String[videoTypes.length];
                String[] speaker = new String[videoTypes.length];
                title[i] = jsonModule.getString("title");
                info[i] = jsonModule.getString("info");
                speaker[i] = jsonModule.getString("speaker");
                Log.i(TAG, "titleArray");
                Log.i(TAG,title[i]);
                Log.i(TAG, "infoArray");
                Log.i(TAG,info[i]);
                Log.i(TAG, "speakerArray");
                Log.i(TAG,speaker[i]);

                bundle.putStringArray("titleArray", title);
                bundle.putStringArray("infoArray", info);
                bundle.putStringArray("speakerArray", speaker);
                bundle.putString("date", strDate);

            }
            intent.putExtras(bundle);

        }

DataList.java

bundle = getIntent().getExtras();
        title = bundle.getStringArray("titleArray");
        Log.i(TAG, "Title Size="+String.valueOf(title.length));
        info = bundle.getStringArray("infoArray");
        Log.i(TAG, "Info Size="+String.valueOf(info.length));
        speaker = bundle.getStringArray("speakerArray");
        Log.i(TAG, "Speaker Size="+String.valueOf(speaker.length));
        date = bundle.getString("date");
        Log.i(TAG, "Bundle Size="+String.valueOf(bundle.size()));
        Log.i(TAG, ""+title[0]);
        //bundle.p
        //title = bundle.getString("title");
        //info = bundle.getString("info");
        //speaker = bundle.getString("speaker");
        for(int i = 0; i < title.length; i++){
            Log.i(TAG, "title["+i+"]"+title[i]);
            Log.i(TAG, "info["+i+"]"+info[i]);
            Log.i(TAG, "speaker["+i+"]"+speaker[i]);
            Log.i(TAG, date);
            Content content = new Content(title[i], info[i], speaker[i], date);
            contentList.add(content);
        }

DDMS:

01-09 18:53:04.305: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.305: INFO/PopulateData(435): ModuleType = v true
01-09 18:53:04.305: INFO/PopulateData(435): ModuleType =  v
01-09 18:53:04.305: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.315: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.315: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.315: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.325: INFO/PopulateData(435): titleArray
01-09 18:53:04.325: INFO/PopulateData(435): Capital Budgeting
01-09 18:53:04.325: INFO/PopulateData(435): infoArray
01-09 18:53:04.325: INFO/PopulateData(435): Bhaavesh bhai will give full to training of Capital budgeting to team deltecs. All the best for him.
01-09 18:53:04.325: INFO/PopulateData(435): speakerArray
01-09 18:53:04.325: INFO/PopulateData(435): Bhaavesh Bhai
01-09 18:53:04.325: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.325: INFO/PopulateData(435): ModuleType = v true
01-09 18:53:04.335: INFO/PopulateData(435): ModuleType =  v
01-09 18:53:04.335: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.345: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.345: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.345: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.345: INFO/PopulateData(435): titleArray
01-09 18:53:04.345: INFO/PopulateData(435): Nixon Cameras
01-09 18:53:04.345: INFO/PopulateData(435): infoArray
01-09 18:53:04.355: INFO/PopulateData(435): Nixon India is a leading camera manufacters in India.
01-09 18:53:04.355: INFO/PopulateData(435): speakerArray
01-09 18:53:04.355: INFO/PopulateData(435): Nixon India
01-09 18:53:04.355: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.365: INFO/PopulateData(435): ModuleType = v true
01-09 18:53:04.365: INFO/PopulateData(435): ModuleType =  v
01-09 18:53:04.365: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.375: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.375: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.375: INFO/DronaDBAdapter(435): Type: v
01-09 18:53:04.385: INFO/PopulateData(435): titleArray
01-09 18:53:04.385: INFO/PopulateData(435): Nixon Cameras
01-09 18:53:04.385: INFO/PopulateData(435): infoArray
01-09 18:53:04.385: INFO/PopulateData(435): Nixon India is a leading camera manufacters in India.
01-09 18:53:04.385: INFO/PopulateData(435): speakerArray
01-09 18:53:04.395: INFO/PopulateData(435): Nixon India
01-09 18:53:04.395: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.395: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.395: INFO/PopulateData(435): ModuleType =  n
01-09 18:53:04.405: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.405: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.405: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.415: INFO/PopulateData(435): ModuleType =  n
01-09 18:53:04.415: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.415: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.415: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.425: INFO/PopulateData(435): ModuleType =  n
01-09 18:53:04.425: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.425: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.425: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.435: INFO/PopulateData(435): ModuleType =  e
01-09 18:53:04.435: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.445: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.445: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.445: INFO/PopulateData(435): ModuleType =  q
01-09 18:53:04.445: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.455: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.455: INFO/PopulateData(435): ModuleType = v false
01-09 18:53:04.455: INFO/PopulateData(435): ModuleType =  s
01-09 18:53:04.465: INFO/PopulateData(435): ModuleType Length =  9
01-09 18:53:04.465: INFO/ActivityManager(59): Starting activity: Intent { cmp=com.drona.app/.DataList (has extras) }
01-09 18:53:04.545: INFO/DataList(435): Title Size=3
01-09 18:53:04.545: INFO/DataList(435): Info Size=3
01-09 18:53:04.545: INFO/DataList(435): Speaker Size=3
01-09 18:53:04.545: INFO/DataList(435): Bundle Size=4
01-09 18:53:04.555: INFO/DataList(435): null
01-09 18:53:04.555: INFO/DataList(435): title[0]null
01-09 18:53:04.555: INFO/DataList(435): info[0]null
01-09 18:53:04.555: INFO/DataList(435): speaker[0]null
01-09 18:53:04.565: INFO/DataList(435): Jan 09
01-09 18:53:04.565: INFO/DataList(435): title[1]null
01-09 18:53:04.565: INFO/DataList(435): info[1]null
01-09 18:53:04.565: INFO/DataList(435): speaker[1]null
01-09 18:53:04.565: INFO/DataList(435): Jan 09
01-09 18:53:04.565: INFO/DataList(435): title[2]Nixon Cameras
01-09 18:53:04.575: INFO/DataList(435): info[2]Nixon India is a leading camera manufacters in India.
01-09 18:53:04.575: INFO/DataList(435): speaker[2]Nixon India
01-09 18:53:04.575: INFO/DataList(435): Jan 09

As appearing in the DDMS, the values that I am passing in the array as bundle in the first activity is getting shown properly, but the when they go to the next activity, they become null. Why is it so? Is there anything wrong I had done?

  • 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-27T23:50:39+00:00Added an answer on May 27, 2026 at 11:50 pm

    This chunk of code is likely your problem:

    bundle.putStringArray("titleArray", title);
    bundle.putStringArray("infoArray", info);
    bundle.putStringArray("speakerArray", speaker);
    bundle.putString("date", strDate);
    

    Each time you go through the loop, you are replacing the previous values because each of the bundled values are keyed to the same key over iterations. You could get around this a couple ways:

    • Use an array of arrays
    • Append a number to the end of each, and put and keep track of the total number that should be available in the bundle so you know how long to loop
    • Put all of this information into some sort of parcelable bean and then parcel each of those beans in your PopulateData
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem regarding getting the path of a user control. The scenario
I have a problem regarding StartUp Url in WPF. I have a LoginView.xaml and
I have a problem regarding the datediff MYSQL function, I can use it and
I have a question regarding a problem with L2S, Autogenerated DataContext and the use
I actually have two questions regarding the same problem but I think it is
Possible Duplicate: Passing Interface in a WCF Service? I've a problem regarding WCF and
I got a problem regarding parsing XML data. I have divided my program into
There was a question regarding passing taking the following function template, and instantiating it
i have a specific problem with pointers and references, with std::vector and std::string. Some
I have a problem reading a txt file to insert in the mysql db

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.