Android打开已有数据库查询

private SQLiteDatabase stuDb;
        /**
         * 查询数据库
         * openOrCreateDatabase(数据库路径,数据库名)
         * rawQuery(Sql语句,参数)
         */
        private void queryDatabase() {
                stuDb = SQLiteDatabase.openOrCreateDatabase(absolutePath + "/" + dbname, null);
                String trim = et_input.getText().toString().trim();
                System.out.println(trim);
                Cursor rawQuery = stuDb.rawQuery("select * from article where id=?", new String[] { trim });
                System.out.println(rawQuery.moveToFirst());
                if (rawQuery.moveToFirst())
                        et_show.setText(rawQuery.getString(1));
        }

 

posted @ 2015-04-17 18:12  小菜希  阅读(796)  评论(0编辑  收藏  举报