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

  • Home
  • SEARCH
  • 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 4618076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:12:54+00:00 2026-05-22T02:12:54+00:00

i am new developer in android applications.i would like to save the data using

  • 0

i am new developer in android applications.i would like to save the data using shared preference concept.i am saving the data in one activity and get the same data in another activity.here i would like to send the String a[]={“one”,”two”,”three”} one activity to another activity.i have written code as follows

Main1.java

public class Main1 extends Activity
 {

  @Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    SharedPreferences shp=getSharedPreferences("TEXT", 0);
    final Editor et=shp.edit();

    ((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            String s1=((EditText)findViewById(R.id.editText1)).getText().toString();
            et.putString("DATA", s1);

            String s2[]={"one","two","three"};

            //here i would like to save the string array

            et.commit();
            Intent it=new Intent(Main1.this,Main2.class);
            startActivity(it);

        }
    });


}

Main2.java

@Override

protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main2);
    String kk=getSharedPreferences("TEXT", 0).getString("DATA", null);

    //here i would like to get the string array of Main1.java

    ((EditText)findViewById(R.id.editText1)).setText(kk);
}

can we get the string array values from Main1.java to Main2.java?

  • 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-22T02:12:55+00:00Added an answer on May 22, 2026 at 2:12 am

    Put it into the starting intent:

    Intent it = new Intent(Main1.this,Main2.class);
    it.putExtra("MY_STRING_ARRAY", s2);
    

    Get it back in the second activity:

    String[] myStringArray = getIntent().getStringArrayExtra("MY_STRING_ARRAY");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new developer on android application. I would like to get the
The new Android 2.1 SDK (version 7) has a new class called SignalStrength: http://developer.android.com/reference/android/telephony/SignalStrength.html
Extreme Android developer newbie here...well, new to Android development, not development in general. I
I'm a new NHibernate developer. I'm using attributes and not map files and I
I am a new android developer and I am currently making an application to
I would like only to start some applications dynamically with the package name from
Hi there Im new to mobile application development. I had developed Android apps using
I would like to know how Android app versioning is done when creating apps
The new Android in-app billing (http://developer.android.com/guide/market/billing/billing_testing.html) page says: To test in-app billing in an
I am not a new developer to android. I have an application on the

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.