/** * create channels helper method * * @param device used to create key in channel */ public static void createChannels(Device device) { List<DataPoint> datapoints = new ArrayList<DataPoint>(); // get devicetype object matching the device Cursor cursor = homeMaticDatabase.query( DatabaseHelper.TABLE_DEVICETYPE, allColumnsDevicetype, DatabaseHelper.COLUMN_DEVICETYPE_HW + " = " + '"' + device.getType() + '"', null, null, null, null); cursor.moveToFirst(); DeviceType deviceType = cursorToDeviceType(cursor); cursor.close(); // get matching datapoints for the devicetype Cursor cursorDP = homeMaticDatabase.query( DatabaseHelper.TABLE_DP, allColumnsDP, DatabaseHelper.COLUMN_DP_CHANNEL_TYPE + " = " + '"' + deviceType.getChannel_type() + '"', null, null, null, null); cursorDP.moveToFirst(); // get all datapoints while (!cursorDP.isAfterLast()) { DataPoint datapoint = cursorToDataPoint(cursorDP); datapoints.add(datapoint); cursorDP.moveToNext(); } cursor.close(); // create as many channels as deviceType.getCnt() with each having all datapoints for (int j = 0; j < deviceType.getCnt(); j++) { createChannel(datapoints, device, j); } }