summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/ApnSettings.java
diff options
context:
space:
mode:
authorHyejin Kim <hyejin.kim@lge.com>2013-02-14 15:49:19 +0900
committerSungmin Choi <sungmin.choi@lge.com>2013-02-16 01:02:30 +0900
commit88c80b10a23f52e5312dcd42565b18854b6dd158 (patch)
treee880e709ac61e8bb82943ae49fa0c3016ece55f9 /src/com/android/settings/ApnSettings.java
parentbbe409d3ce08d5d463721bd23b76a65dc83d38d6 (diff)
downloadpackages_apps_Settings-88c80b10a23f52e5312dcd42565b18854b6dd158.tar.gz
packages_apps_Settings-88c80b10a23f52e5312dcd42565b18854b6dd158.tar.bz2
packages_apps_Settings-88c80b10a23f52e5312dcd42565b18854b6dd158.zip
avoid stopping app in case of accessing empty db
When accessing empty database, Setting App is stopped, sometimes. To avoid stopping app, check null for cursor Change-Id: I71ec067f502d12a9215a9abdbe9e23fc07af17bb
Diffstat (limited to 'src/com/android/settings/ApnSettings.java')
-rw-r--r--src/com/android/settings/ApnSettings.java72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java
index de1ce635d..3fbb5e3ab 100644
--- a/src/com/android/settings/ApnSettings.java
+++ b/src/com/android/settings/ApnSettings.java
@@ -164,43 +164,45 @@ public class ApnSettings extends PreferenceActivity implements
"_id", "name", "apn", "type"}, where, null,
Telephony.Carriers.DEFAULT_SORT_ORDER);
- PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
- apnList.removeAll();
-
- ArrayList<Preference> mmsApnList = new ArrayList<Preference>();
-
- mSelectedKey = getSelectedApnKey();
- cursor.moveToFirst();
- while (!cursor.isAfterLast()) {
- String name = cursor.getString(NAME_INDEX);
- String apn = cursor.getString(APN_INDEX);
- String key = cursor.getString(ID_INDEX);
- String type = cursor.getString(TYPES_INDEX);
-
- ApnPreference pref = new ApnPreference(this);
-
- pref.setKey(key);
- pref.setTitle(name);
- pref.setSummary(apn);
- pref.setPersistent(false);
- pref.setOnPreferenceChangeListener(this);
-
- boolean selectable = ((type == null) || !type.equals("mms"));
- pref.setSelectable(selectable);
- if (selectable) {
- if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
- pref.setChecked();
+ if (cursor != null) {
+ PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
+ apnList.removeAll();
+
+ ArrayList<Preference> mmsApnList = new ArrayList<Preference>();
+
+ mSelectedKey = getSelectedApnKey();
+ cursor.moveToFirst();
+ while (!cursor.isAfterLast()) {
+ String name = cursor.getString(NAME_INDEX);
+ String apn = cursor.getString(APN_INDEX);
+ String key = cursor.getString(ID_INDEX);
+ String type = cursor.getString(TYPES_INDEX);
+
+ ApnPreference pref = new ApnPreference(this);
+
+ pref.setKey(key);
+ pref.setTitle(name);
+ pref.setSummary(apn);
+ pref.setPersistent(false);
+ pref.setOnPreferenceChangeListener(this);
+
+ boolean selectable = ((type == null) || !type.equals("mms"));
+ pref.setSelectable(selectable);
+ if (selectable) {
+ if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
+ pref.setChecked();
+ }
+ apnList.addPreference(pref);
+ } else {
+ mmsApnList.add(pref);
}
- apnList.addPreference(pref);
- } else {
- mmsApnList.add(pref);
+ cursor.moveToNext();
}
- cursor.moveToNext();
- }
- cursor.close();
+ cursor.close();
- for (Preference preference : mmsApnList) {
- apnList.addPreference(preference);
+ for (Preference preference : mmsApnList) {
+ apnList.addPreference(preference);
+ }
}
}
@@ -330,7 +332,7 @@ public class ApnSettings extends PreferenceActivity implements
switch (msg.what) {
case EVENT_RESTORE_DEFAULTAPN_START:
ContentResolver resolver = getContentResolver();
- resolver.delete(DEFAULTAPN_URI, null, null);
+ resolver.delete(DEFAULTAPN_URI, null, null);
mRestoreApnUiHandler
.sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_COMPLETE);
break;