a = listb.append(3)

这种形式的赋值是有问题的,结果是a 没有赋值,而是none。
因为.append()是在列表b后面追加元素,并没有返回值,所以没有值赋给a

package com.example.a7_1.DAO; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.example.a7_1.model.flag; import java.util.ArrayList; import java.util.List; public class FlagDao { private DBOpenHelper helper; private SQLiteDatabase db; public FlagDao (Context context){ helper = new DBOpenHelper(context) } public void add(flag flag){ db = helper.getWritableDatabase(); db.execSQL("insert into tb_flag (_id,flag) values (?,?)",new Object[]{ flag.getid(),flag.getFlag() }); } public void update(flag tb_flag){ db = helper.getWritableDatabase(); db.execSQL("update tb_flag set flag = ? where _id=?",new Object[]{ tb_flag.getFlag(), tb_flag.getid() } ); } public flag find(int id){ db = helper.getWritableDatabase(); Cursor cursor = db.rawQuery("select _id,flag from tb_flag where _id = ?",new String[]{String.valueOf(id)}); if(cursor.moveToNext()){ return new flag(cursor.getInt(cursor.getColumnIndex(("_id")),cursor.getString(cursor.getColumnIndex("flag"))); } return null; } public void delete(Integer... ids){ if(ids.length>0){ StringBuffer sb = new StringBuffer(); for (int i= 0; i<ids.length;i++){ sb.append('?').append(','); } sb.deleteCharAt(sb.length() -1); db = helper.getWritableDatabase(); db.execSQL("delete from tb_flag where _id in ("+ sb +")",(Object[]) ids); } } public List<flag> getScrollDate(int start,int count){ List<flag> lisTb_flags = new ArrayList<flag>(); db = helper.getWritableDatabase(); Cursor cursor = db.rawQuery("select * from tb_flag limit ?,?",new String[]{String.valueOf(start),String.valueOf(count)}); while (cursor.moveToNext()){ lisTb_flags.add(new flag(cursor.getInt(cursor.getColumnIndex("_id")),cursor.getString(cursor.getColumnIndex("flag")))); } return lisTb_flags; } public long getCount(){ db = helper.getWritableDatabase(); Cursor cursor = db.rawQuery("select count(_id) from tb_falg",null); if(cursor.moveToNext()){ return cursor.getLong(0); } return 0; } public int getMaxId(){ db = helper.getWritableDatabase(); Cursor cursor = db.rawQuery("select max(_id) from tb_falg",null); while (cursor.moveToNext()){ return cursor.getInt(0); } return 0; } }检查代码问题
05-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值