在线等!!!求大神救命!!!我的sqlite插入的5条数据都没有显示

老师让我们做的是一个安卓学生成绩管理系统
我创建了一个学生类表 有stuid stuname stusex wuli shuxue yingyu jisuanji
就是四科成绩加上一些个人信息
然后我现在想通过插入五条数据 先显示他们5个人的名字
然后通过名字点击item跳转到他们的详细信息ACTIVITY
但是!!
崩溃啊!!
我自己研究了4天都没弄好才敢上来问啊
这对我很重要啊 希望大神表要吝啬教小弟啊
 现在贴一下主函数list 的代码
public class list extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        DBHelper helper = new DBHelper(this,null,null,1);
        SQLiteDatabase database = helper.getWritableDatabase(); 

    
             database.execSQL("INSERT INTO Student VALUES (stuid,stuname,stusex,wuli,shuxue,yingyu,shuxue)", new Object[]{131,"小红","女",88,77,85,46}); 
          database.execSQL("INSERT INTO Student VALUES (?,?,?,?,?,?,?)", new Object[]{10002,"小红","女",88,77,85,46}); 
          database.execSQL("INSERT INTO Student VALUES (?,?,?,?,?,?,?)", new Object[]{10003,"小蓝","男",88,78,65,22});
           database.execSQL("INSERT INTO Student VALUES (?,?,?,?,?,?,?)", new Object[]{10004,"小绿","男",88,77,55,55});
          database.execSQL("INSERT INTO Student VALUES (?,?,?,?,?,?,?)", new Object[]{10005,"小黄","男",88,75,55,98});
          database.execSQL("INSERT INTO Student VALUES (?,?,?,?,?,?,?)", new Object[]{10006,"小青","女",88,77,59,82});
       
          String sql = "select * from Student  where stuid = ?";
          String[] args = {Student.stuid + ""};
          Cursor cursor = helper.getReadableDatabase().rawQuery(sql, args);
          
          while (cursor.moveToNext()) {
                  Student student = new Student();
                  student.setId(cursor.getInt(0));
                  }
          helper.close();
       
    }
    @Override
    public void onListItemClick(ListView parent,View v, int position, long id){ 
     super.onListItemClick(parent, v, position, id);
     Intent intent=new Intent();
     if (0==position){
     intent.setClass(list.this,MainActivity.class);
     list.this.startActivity(intent);
     list.this.finish();
     }
    }
}详细信息的第二个activity的代码
public class MainActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值