2012-10-17 113 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 :) –