2013-03-19 62 views
0

嗨,我希望與小計相比,我的送貨費用和計算送貨費用。我成功地得到了結果。 我得到查詢,我把代碼執行在執行SQL.I得到了正確的答案。但Android中的數據庫Sqllite問題?

我在檢索數據中有一些問題。我每次得到結果的第一個位置值只。

下面我提到我的code.Give我的解決方案。

String Query ="select ROUND(delivarycharge) from pincodedetails where ROUND(subtotal) 
<= (select ROUND(subtotal) from pincodedetails where ROUND(subtotal) >= "+price+" 
and resturantID="+selArgs+" limit 1) and resturantID ="+selArgs+" and ROUND(subtotal) 
>= (select ROUND(subtotal) from pincodedetails where ROUND(subtotal) <= "+price+" 
and resturantID="+selArgs+" limit 1) order by ROUND(subtotal) LIMIT 1"; 

數據庫助手類:

double deliverycharge= 0; 
if (mCursor.moveToFirst()) { 
    // Got first result 
    deliverycharge= mCursor.getDouble(0); 
} 
return deliverycharge; 

回答

1

你應該改變你的代碼來檢索類似:

Vector<String> temp = new Vector<String>; 
cursor.moveToFirst(); 
do { 

    deliverycharge= mCursor.getDouble(0); 
    temp.add()     
} while (cursor.moveToNext()); 
return temp; 

所以,你會返回一個包含所有字符串一個縮放的矢量。

+0

我得到的結果只有一個sunhari.No需要列表和所有 – Gomathi 2013-03-19 07:20:00

+0

如果您需要檢索的所有字符串,然後你怎麼能沒有向量或列表或String []? @Gomathi – 2013-03-19 07:21:40

+0

因爲每一次字符串都會被覆蓋@Gomathi – 2013-03-19 07:23:17

0

試試這個

String Query ="select ROUND(delivarycharge) as roundcharge from pincodedetails where ROUND(subtotal) <=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)>="+price+" and resturantID="+selArgs+" limit 1) and resturantID="+selArgs+" and ROUND(subtotal) >=(select ROUND(subtotal) from pincodedetails where ROUND(subtotal)<="+price+" and resturantID="+selArgs+" limit 1) order by ROUND(subtotal) LIMIT 1"; 

你需要的是「任何你想要的名稱」