Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - value results to "infinity" when multiplied by value fetched from SQLite database
    text
    copied!<p>Iam trying to fetch a value from the last row in my sqlite database and use it for multiplication and division in my main activity to get a certain result. But I get the multiplication result as 0 and division result as "infinity". Can anyone help!!</p> <p>heres the code</p> <pre><code> food.java (main activity) { //user inputs ETRate = (EditText)findViewById(R.id.ETRate); ETFoodQty =(EditText)findViewById(R.id.ETFoodQty; ETRate.setOnFocusChangeListener(this); ETFoodQty.setOnFocusChangeListener(this); FoodStorage foodGetInfo = new FoosStorage(this); foodGetInfo.open(); foodGetInfo.getAvgTotal(this); foodGetInfo.close(); chkLastTotal1.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub isChkLastTotal1=true; } }); public void onFocusChange(View predictionFocusView, boolean hasPredictionETFocus) { if(ETRate.isFocused()) { if(foodQty!=0) //here I get rate =0 { rate =(long) (lastTotal*foodQty); setRate(rate); ETRate.setText(String.valueOf(rate)); } } else if(foodQty.isFocused()) //Here I get foodQty = infinity { if(rate!=0) { foodQty =rate/avgtotal; setPredictFoodQty(foodQty); ETfoodQty.setText(String.valueOf(foodQty)); } } foodStorage.java (database file) public void getAvgtotal(food pd) { String [] columns = new String[]{KEY_ROW_ID, KEY_RATE, KEY_FOOD_QTY, KEY_FOOD_PRICE, KEY_QUALITY, KEY_TOTAL, KEY_DATE,KEY_GRADE}; if(pd.isChkLastTotal1()==true) { Cursor c= ourDatabase.rawQuery("SELECT * FROM food_table ORDER BY _id DESC LIMIT 1", null); c.moveToFirst(); if(c!=null &amp;&amp; c.getCount()&gt;0) { c.moveToLast(); String getLastTotal =c.getString(5); food myFoodInfo = new Food(); myFoodInfo.setavgTotal(Double.parseDouble(getLastTotal)); } c.close(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload