Java 如何将Double类型的数据插入phpmyadmin?

Java 如何将Double类型的数据插入phpmyadmin?,java,android,eclipse,phpmyadmin,Java,Android,Eclipse,Phpmyadmin,我正在使用eclipse创建一个android应用程序,它将读取用户输入的价格 输入的价格应存储到数据库(phpmyadmin) 我正在使用下面的代码,但eclipse出现错误,要求我将double转换为字符串 food = Double.parseDouble(inputFood.getText().toString()); transport = Double.parseDouble(inputTransport.getText().toStr

我正在使用eclipse创建一个android应用程序,它将读取用户输入的价格

输入的价格应存储到数据库(phpmyadmin)

我正在使用下面的代码,但eclipse出现错误,要求我将double转换为字符串

            food = Double.parseDouble(inputFood.getText().toString());
            transport = Double.parseDouble(inputTransport.getText().toString());
            tele = Double.parseDouble(inputTele.getText().toString());
            academic = Double.parseDouble(inputAcademic.getText().toString());
            entertainment = Double.parseDouble(inputEntertainment.getText().toString());
            health = Double.parseDouble(inputHealth.getText().toString());
            others = Double.parseDouble(inputOthers.getText().toString());
            budget = Double.parseDouble(inputBudget.getText().toString());

            total = food + transport + tele + academic + entertainment + health + others;          
            balance = budget - total;

           List<NameValuePair> params = new ArrayList<NameValuePair>();
           params.add(new BasicNameValuePair("food", food));
           params.add(new BasicNameValuePair("transport", transport));
           params.add(new BasicNameValuePair("tele", tele));
           params.add(new BasicNameValuePair("academic", academic));
           params.add(new BasicNameValuePair("entertainment", entertainment));
           params.add(new BasicNameValuePair("health", health));
           params.add(new BasicNameValuePair("others", others));
           params.add(new BasicNameValuePair("budget", budget));
           params.add(new BasicNameValuePair("total", total));
           params.add(new BasicNameValuePair("balance", balance));

           JSONObject json = jsonParser.makeHttpRequest(url_save_expenses,
                               "GET", params);
food=Double.parseDouble(inputFood.getText().toString());
transport=Double.parseDouble(inputTransport.getText().toString());
tele=Double.parseDouble(inputTele.getText().toString());
学术=Double.parseDouble(inputAcademic.getText().toString());
entertainment=Double.parseDouble(inpuntertainment.getText().toString());
health=Double.parseDouble(inputHealth.getText().toString());
其他=Double.parseDouble(inputOthers.getText().toString());
budget=Double.parseDouble(inputBudget.getText().toString());
总计=食物+交通+电话+学术+娱乐+健康+其他;
余额=预算-总额;
List params=new ArrayList();
参数添加(新的BasicNameValuePair(“食品”,食品));
参数添加(新的BasicNameValuePair(“传输”,传输));
参数添加(新的BasicNameValuePair(“tele”,tele));
参数添加(新的BasicNameValuePair(“学术”,学术));
参数添加(新的BasicNameValuePair(“娱乐”,娱乐));
参数添加(新的BasicNameValuePair(“健康”,健康));
参数添加(新的BasicNameValuePair(“其他”,其他));
参数添加(新的BasicNameValuePair(“预算”,预算));
参数添加(新的BasicNameValuePair(“总计”,总计));
参数添加(新的BasicNameValuePair(“余额”,余额));
JSONObject json=jsonParser.makeHttpRequest(url\u save\u),
“得到”,params);
是否有其他编码用于存储双重数据


谢谢你的回答

用这种方式编写在列表中添加参数的代码即可

       params.add(new BasicNameValuePair("food", "" + food));
       params.add(new BasicNameValuePair("transport", "" + transport));
       params.add(new BasicNameValuePair("tele", "" + tele));
       params.add(new BasicNameValuePair("academic", "" + academic));
       params.add(new BasicNameValuePair("entertainment", "" + entertainment));
       params.add(new BasicNameValuePair("health", "" + health));
       params.add(new BasicNameValuePair("others", "" + others));
       params.add(new BasicNameValuePair("budget", "" + budget));
       params.add(new BasicNameValuePair("total", "" + total));
       params.add(new BasicNameValuePair("balance", "" + balance));

这会将此构造函数的double类型更改为string,并在服务器端将string转换为double并存储到数据库中

感谢您的回复。我的程序现在没有错误,但数据仍然无法存储到数据库中。结果是“不幸的是,系统已停止”