当我运行以下代码时,我会在 Toast 消息中显示此异常:Java.lang.IllegalStateExcepton: Bad request for field slot 0,-1. numRows = 1, numColumns = 1
.
SQLiteDatabase sb;
String g="o";
try {
sb=SQLiteDatabase.openDatabase("data/data/com.example.datatestx/ma", null, SQLiteDatabase.CREATE_IF_NECESSARY);
sb.execSQL("create table if not exists blac (" + " phone text , " + " ftime text, " + " ttime text ); " );
sb.execSQL( "insert into blac(phone, ftime,ttime) values ('01711233434', '333333','33333' );" );
sb.execSQL( "insert into blac(phone, ftime,ttime) values ('01761233433', '777' ,'77777');" );
sb.execSQL( "insert into blac(phone, ftime,ttime) values ('01712333323', '999','33433' );" );
Cursor c1 = sb.rawQuery( "select count(*) as Total from blac", null);
if(c1.getCount()>0){
c1.moveToFirst();
do {
g=g+c1.getString(c1.getColumnIndex("phone"));
}while(c1.moveToNext());
} c1.close();
sb.close();
Toast.makeText(getApplicationContext(), "Success!"+g, Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
}
我不知道为什么这不起作用。有人可以帮忙吗?