Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在datamodel中将空值设置为空数据如何删除绑定异常的数组索引 String productname[]=dbHelper.getProductName(“Basmati Rice”); dbHelper.open(); 字符串productQuantity[]=dbHelper.getProductQuantity(“basmatirice”); dbHelper.open(); 字符串productCost[]=dbHelper.getProductCost(“basmatirice”); dbHelper.open(); 字符串productcount[]=dbHelper.getpurchesitemCount(); List lstDataModel=newarraylist(); 对于(int i=0;i_Java_Android_Sqlite - Fatal编程技术网

Java 如何在datamodel中将空值设置为空数据如何删除绑定异常的数组索引 String productname[]=dbHelper.getProductName(“Basmati Rice”); dbHelper.open(); 字符串productQuantity[]=dbHelper.getProductQuantity(“basmatirice”); dbHelper.open(); 字符串productCost[]=dbHelper.getProductCost(“basmatirice”); dbHelper.open(); 字符串productcount[]=dbHelper.getpurchesitemCount(); List lstDataModel=newarraylist(); 对于(int i=0;i

Java 如何在datamodel中将空值设置为空数据如何删除绑定异常的数组索引 String productname[]=dbHelper.getProductName(“Basmati Rice”); dbHelper.open(); 字符串productQuantity[]=dbHelper.getProductQuantity(“basmatirice”); dbHelper.open(); 字符串productCost[]=dbHelper.getProductCost(“basmatirice”); dbHelper.open(); 字符串productcount[]=dbHelper.getpurchesitemCount(); List lstDataModel=newarraylist(); 对于(int i=0;i,java,android,sqlite,Java,Android,Sqlite,这是我的代码我得到的数组索引超出了绑定异常,因为我只有3个productcount大小,其他有4个string数组计数,但循环运行了4次,因为我正在执行4个Length循环我想在datamodel中将值设置为空如果值为空,请告诉我如何在java中修复它 String productname[] = dbHelper.getProductName("Basmati Rice"); dbHelper.open(); String productQuantity[]

这是我的代码我得到的数组索引超出了绑定异常,因为我只有3个productcount大小,其他有4个string数组计数,但循环运行了4次,因为我正在执行4个Length循环我想在datamodel中将值设置为空如果值为空,请告诉我如何在java中修复它

  String productname[] = dbHelper.getProductName("Basmati Rice");
        dbHelper.open();
        String productQuantity[] = dbHelper.getProductQuantity("Basmati Rice");
        dbHelper.open();
        String productCost[] = dbHelper.getProductCost("Basmati Rice");
        dbHelper.open();
        String   productcount[] = dbHelper.getpurchesitemCount();
        List<DataModel> lstDataModel = new ArrayList<DataModel>();
        for (int i = 0; i < productname.length; i++) {
            DataModel datamodel = new DataModel();
            datamodel.setProdcutid(productId[i]);
            datamodel.setProductname(productname[i]);
            datamodel.setProdcutQuantity(productQuantity[i]);
            datamodel.setProdcutCost(productCost[i]);
            datamodel.setEachproductcount(productcount[i]);

            lstDataModel.add(datamodel);
        }
datamodel.setEachproductcount(i
datamodel.setEachproductcount( i < productcount.length ? productcount[i] : null);