loginTest = SQLiteDatabase.openOrCreateDatabase("data/data/com.stephen.sqltest/databases/Login_test_db",null);
String sql = "Select pass from user where name="+user;
int tep=0;
Cursor cursor = loginTest.rawQuery(sql,null);
cursor.moveToFirst();
try {
int tepm =cursor.getInt(cursor.getColumnIndex("pass"));
Toast.makeText(SqlTest.this, tepm+" ", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(SqlTest.this, tep+" "+"下方", Toast.LENGTH_SHORT).show();
}
CREATE TABLE android_metadata (locale TEXT);
CREATE TABLE user(id int,name varchar(20),pass int);
sqlite> insert into user values( 1,'stephen',123456)
insert into user values( 1,'stephen',123456);
sqlite> select * from user;
select * from user;
1|stephen|123456
另外,把你代码中的sql文件拷贝到终端中或者把db pull到pc上,用工具查看,看看能不能查出来。
"Select pass from user where name="+user;