この次のコードを実行すると、トースト メッセージに次の例外が表示されます: 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();
}
なぜこれが機能しないのかわかりません。誰でも助けることができますか?