2012-10-17 42 views
2

這是我的光標我的函數來獲取查詢:得到SUM函數

public Cursor getSaldo(String id) { 
     String[] args={id}; 
     return(getReadableDatabase() 
     .rawQuery("SELECT sum("+t_jumlah+") "+ 
       "as "+t_saldo+" "+ 
       "FROM "+t_table+" WHERE "+t_nId+"=?", args)); 

我能做些什麼來把數據放到我TextView

我有光標這樣

almagId=getIntent().getStringExtra(Nasabah.ID_EXTRA); 

Cursor c=helper.getSaldo(almagId); 
startManagingCursor(c); 

回答

0

你可以做這樣的事情。只是試一試

if(!cursor.moveToFirst()){ 
mytextView.setText("No output"); 
} 
else{ 
do { 
mytextView.setText(cursor.getString(0)); 

} while (cursor.moveToNext()); 
+1

Alhamdulillah它工作把數據放在我的textview。非常感謝。 –

+0

很高興聽到它幫助你。快樂編碼 –

+0

呵呵,感謝Sharath :) –