public ArrayList<String> getSecondaryProfileList(Context ctx) { ArrayList<String> temp = new ArrayList<String>(); dbUtil = new DatabaseUtil(ctx); dbUtil.open(); Cursor cursor = dbUtil.fetchSecondaryProfileList(); if (cursor != null) { String str = new String(); str = cursor.getString(0); temp.add(str); while (cursor.moveToNext()) { str = new String(); str = cursor.getString(0); temp.add(str); } } else Toast.makeText(ctx, "Cannot load profile", Toast.LENGTH_LONG); dbUtil.close(); return temp; }