From 718e01c219b030b90e0714c6af65c860719b9cfc Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 10 Mar 2014 19:21:38 +0100 Subject: Fix NPE reported by dev console --- .../de/blinkt/openvpn/activities/ConfigConverter.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'main') diff --git a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java index 9dee3557..92356a20 100644 --- a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java +++ b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java @@ -527,22 +527,25 @@ public class ConfigConverter extends Activity implements FileSelectCallback { InputStream is = getContentResolver().openInputStream(data); mPathsegments = data.getPathSegments(); + Cursor cursor = null; + if (data!=null) + cursor = getContentResolver().query(data, null, null, null, null); + - Cursor cursor = getContentResolver().query(data, null, null, null, null); try { if (cursor!=null && cursor.moveToFirst()) { - int cidx = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); + int columnIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); - if (cidx != -1) { - String displayName = cursor.getString(cidx); + if (columnIndex != -1) { + String displayName = cursor.getString(columnIndex); if (displayName != null) possibleName = displayName; } - cidx = cursor.getColumnIndex("mime_type"); - if (cidx != -1) { - log("Opening Mime TYPE: " + cursor.getString(cidx)); + columnIndex = cursor.getColumnIndex("mime_type"); + if (columnIndex != -1) { + log("Opening Mime TYPE: " + cursor.getString(columnIndex)); } } } finally { -- cgit v1.2.3