| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 423 人关注过本帖
标题:求帮忙啊看看怎么获取已经存进去的数据
取消只看楼主 加入收藏
王洋爱135
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2012-8-15
结帖率:0
收藏
 问题点数:0 回复次数:0 
求帮忙啊看看怎么获取已经存进去的数据
dpress.setOnClickListener(new android.view.View.OnClickListener()
            {
            public void onClick(View v)
            {
                db = new Sql(getApplicationContext(), "store.db", null, 1);
                sDatabase = db.getWritableDatabase();
                if (userName01.getText().toString().equals("")
                                || password01.getText().toString().equals(""))
                {

                            DialogDemo.builder(AssistantRegister.this, "错误信息", "请填写完整信息!");

                        
                }



public void onClick(View v)
            {
                String i = use.getText().toString();
                //String i1 = password.getText().toString();
                String userName = "";
                String userPw = "";
                //编写数据库语句
                String select_sql = "select username,password from user_info where username = '"
                        + i + "'";
                //执行语句
                Cursor cursor = sDatabase.rawQuery(select_sql, null);
                if(cursor!=null){
                cursor.moveToFirst();
               
                try
                {
                    
                    userName = cursor.getString(1);
                    userPw = cursor.getString(2);
                    
                }
                catch (Exception e)
                {
                    // TODO: handle exception
                    userName = "";
                    userPw = "";
                }}

                else
                {
                    int id1=0;
                    String select = "select max(_id) from user_info";
                    Cursor seCursor = sDatabase.rawQuery(select, null);
                    seCursor.moveToFirst();
                    id1 = Integer.parseInt(seCursor.getString(0));
                    id1 += 1;
                    sDatabase.execSQL("insert into user_info values('" + id1 + "','"
                                            + userName01 + "','" + password01 + "')"
                                            );
                    DialogDemo.builder(AssistantRegister.this, "提示", "注册成功,请返回登录界面登录");
                                    //seCursor.close();
                                    sDatabase.close();
                 
                    
                }
主要是怎么获取数据库中的数据那里可能出错了,但不知怎么改正
搜索更多相关主题的帖子: equals void public null 
2012-08-16 16:32
快速回复:求帮忙啊看看怎么获取已经存进去的数据
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018362 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved