学习技能:sqlitebrowser.exe工具创建sqlite数据库,创建表,添加数据,把数据库添加到项目中。
使用了assets文件夹。该文件夹用于把资源压缩到apk。然后程序启动判断是否存在该文件,不存在该文件就复制该文件到指定目录。
使用radiobutton结合radio来呈现试题。
db=SQLiteDatabase.openDatabase("/data/data/com.example.qa_android/databases/qa.db", null,SQLiteDatabase.OPEN_READWRITE);
public List getQeustions()
{
List list=new ArrayList();
Cursor cursor=db.rawQuery("select * from question", null);
if(cursor.getCount()>0)
{
cursor.moveToFirst();
for(int i=0;i
{
cursor.moveToPosition(i);
Question question=new Question();
question.ID=cursor.getInt(cursor.getColumnIndex("ID"));
question.Question=cursor.getString(cursor.getColumnIndex("Question"));
question.AnswerA=cursor.getString(cursor.getColumnIndex("AnswerA"));
question.AnswerB=cursor.getString(cursor.getColumnIndex("AnswerB"));
question.AnswerC=cursor.getString(cursor.getColumnIndex("AnswerC"));
question.AnswerD=cursor.getString(cursor.getColumnIndex("AnswerD"));
question.AnswerDEsc=cursor.getString(cursor.getColumnIndex("AnswerDEsc"));
question.Answer=cursor.getInt(cursor.getColumnIndex("Answer"));
question.selectAnswer=-1;
list.add(question);
}
}
return list;
}