我是Android的新手。我正在尝试使用SQLite更新我的第一个应用程序中的表。但当ı从SQLite经理看到表时,看到表没有更新。我找不到问题所在?
public void EntryHesapla(int yilsql, String aysql,int digerTaksitlersql,
int digersql,int maasSelosql,int maasHilalsql,int digerGelirlersql,
int toplamHarcamasql,int toplamGelirsql,int eldeKalansql) {
ContentValues cv = new ContentValues();
cv.put(C_YIL, yilsql);
cv.put(C_AY, aysql);
cv.put(C_DIGERTAKSITLER, digerTaksitlersql);
cv.put(C_DIGER, digersql);
cv.put(C_MAASSELO, maasSelosql);
cv.put(C_MAASHILAL, maasHilalsql);
cv.put(C_DIGERGELIRLER, digerGelirlersql);
cv.put(C_TOPLAMHARCAMA, toplamHarcamasql);
cv.put(C_TOPLAMGELIR, toplamGelirsql);
cv.put(C_ELDEKALAN, eldeKalansql);
String[] selectionArgs=new String[]{yilsql+"", aysql};
String entryHesaplaSQL="SELECT c_id FROM harcamalar WHERE "+C_YIL+"= ? AND "+C_AY+"= ?";
Cursor cursor=ourDatabase.rawQuery(entryHesaplaSQL, selectionArgs);
cursor.moveToFirst();
cursor.moveToPosition(cursor.getCount() - 1);
int index=cursor.getInt(cursor.getColumnIndex(C_ID));
if(index>=0)
ourDatabase.update(DB_TABLE, cv, C_ID+"="+index, null);
else ourDatabase.insert(DB_TABLE, null, cv);
}
答案 0 :(得分:1)
cursor.getColumnIndex(C_ID);
返回查询中C_ID列的列索引。它为0,因为查询中只有1列。
如果您想要此列的值,则需要致电getInt(index)
(有关详细信息,请参阅getColumnIndex。)