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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:55:35+00:00 2026-06-10T18:55:35+00:00

I have an activity that load sharedPreference from another activity and put some data

  • 0

I have an activity that load sharedPreference from another activity and put some data from the
sharedPreferenece into a listView using the arrayAdpter when I compile my app its forced close
this is me code:

public class DawaaActivity extends Activity implements View.OnClickListener {
/** Called when the activity is first created. */
Button add;
ListView dataList;
private SharedPreferences emportPref;
String[] dawaaList;
String theName;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    initialaiz();
    emportPref = getSharedPreferences("dawaaData", MODE_PRIVATE);
    theName = emportPref.getString("subject", "no data found");
    Toast.makeText(this, theName, Toast.LENGTH_LONG).show();
    dawaaList[0] = theName;
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,dawaaList);
    dataList.setAdapter(adapter);
}

private void initialaiz() {
    // TODO Auto-generated method stub
    add = (Button) findViewById(R.id.button3);
    dataList = (ListView) findViewById(R.id.myListView);
    add.setOnClickListener(this);
}

public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent data = new Intent(DawaaActivity.this,SettingActivity.class);
    startActivity(data);
}

when I make this two line if code hinted :

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,dawaaList);
    dataList.setAdapter(adapter)

the app is work just fine

but not filling the listView Of course

help me please

  • 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-06-10T18:55:37+00:00Added an answer on June 10, 2026 at 6:55 pm

    I think you forgot to initialize String[] with proper size,

    Instead of

    String[] dawaaList;
    

    try

    String[] dawaaList = new String[1];
    

    The line which throws Exception is,

    dawaaList[0] = theName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView Activity that uses a AsyncTask to load data from the
I have an activity that lets the user load some data when they press
I have Activity with some data displayed in WebView that I load with WebView#loadDataWithBaseURL
I have activity that load's image from server into imageview. Image is displayed after
I have an activity that I'd like to load from a preference screen. I'm
I have various pieces of generated HTML/JS that I load into Activity with WebView#loadDataWithBaseURL.
I have an Activity that retrieves data from a web service. This data is
I have an Activity that displays a text based on data pulled from MySQL
I have an activity that loads some content using an AsyncTask. If the content
I have an implementation file that load data from rss in the internet, parse

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.