I am creating a application with preference activity where the listpreference entries are problematically assigned. This application works fine on my emulator but while i test my application in mobile it shows error like this
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
at android.widget.AbsListView.obtainView(AbsListView.java:2033)
This problem arises when i click that listpreference in my mobile. here this is my code
prference.xml
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/settings">
<ListPreference
android:key="@string/resolution"
android:title="@string/imageres"
android:summary="@string/summaryres"
android:dialogTitle="@string/resFormat"
/>
</PreferenceCategory>
</PreferenceScreen>
settings.java
package com.example;
import android.database.Cursor;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
public class Settings extends PreferenceActivity {
private SQLiteoperations SQLiteAdapter;
DTO get;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
get = (DTO) getIntent().getExtras().get("obj");
SQLiteAdapter = new SQLiteoperations(this);
SQLiteAdapter.openToWrite();
addPreferencesFromResource(R.xml.preferences);
ListPreference pref = (ListPreference) findPreference("resolution");
pref.setEntries(getEntries());
pref.setEntryValues(getEntries());
System.out.println("after set entries");
System.