Note that there are some explanatory texts on larger screens.

plurals
  1. POShared Preferences Crashes Program
    primarykey
    data
    text
    <p>Im trying to make a world creator in a list view that saves the world's name. But the shaed preferences causes the program to crash before the activity opens. Why is this happening? It is perfectly fine without the shared preferences. Any ideas? (that on list view click is unfinished, don't worry about that.) The errors that were most notable were the null pointerexception at the array adapter, storage == null, and skipped frames</p> <pre><code>package xxx.xxx.xxx; import android.app.ListActivity; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.PopupWindow; public class WorldMenu extends ListActivity{ SharedPreferences prefs; String splitter; String[] worldList; PopupWindow worldNamer; Drawable background; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(WorldMenu.this, android.R.layout.simple_list_item_1, worldList)); prefs = getSharedPreferences("worldString", 0); splitter = "Create World\\\\\\\\\\\\\\\\\\\\\\\\\\" + prefs.getString("worldString", "No worlds found."); worldList = splitter.split("\\\\\\\\\\\\\\\\\\\\\\\\\\"); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); if(position == 0){ worldNamer = new PopupWindow(this); worldNamer.setBackgroundDrawable(null); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload