我通过单击1个列表中的元素将其自动移到了其他三个列表中。通过单击第一个列表的第一个值,第一个列表具有3个值,没有错误;同样,通过单击第二个和第三个列表的第一个和第二个值,也没有错误,但是单击第三个值会引发错误,并且输出时列表为空
我更改了要从中获取数据的表中的另一个
package com.ayesha.judicial_provision;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;
public class database extends SQLiteOpenHelper {
static String DATABASE_NAME="JD_PROVISION_DB";
private static final int DataBase_Version=1;
///////////LAWSDB////////////
public static final String LAW_TABLE_NAME="Laws_Table";
public static final String KEY_ID="id";
public static final String Key_Category="Category_Name";
public static final String key_Sub_Category="Sub_Category_name";
public static final String LAW_Name="Law_name";
public static final String Key_Law_Number="Law_number";
public static final String KEY_Subject="subject";
public static final String Key_Description="Description";
public static final String Key_Condition="Condition";
public static final String Key_Panelty="Panelty";
public static final String Key_Date="Date";
@Override
public void onCreate(SQLiteDatabase database) {
///////LAWSDB/////////
String CREATE_TABLE7="CREATE TABLE "+LAW_TABLE_NAME+" ("+KEY_ID+" INTEGER PRIMARY KEY AUTOINCREMENT,"+Key_Category+" TEXT, "+key_Sub_Category+" TEXT," +
""+Key_Law_Number+" TEXT, "+LAW_Name+" TEXT, "+KEY_Subject+" TEXT, "+Key_Description+" TEXT," +
" "+Key_Condition+" TEXT, "+Key_Panelty+" TEXT, "+Key_Date+" TEXT )";
database.execSQL(CREATE_TABLE7);
Log.d("Table ",CREATE_TABLE7);
@override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS JD_PROVISION_DB"+LAW_TABLE_NAME);
onCreate(db);
}
// laws
public void addFemaleProtectionLaws(Context c){
SQLiteDatabase db=this.getWritableDatabase();
ContentValues cv=new ContentValues();
cv.put(Key_Category,"FemaleProtectionAct");
cv.put(key_Sub_Category,"Spreading False Information");
cv.put(KEY_Name," False Information ");
cv.put(KEY_Subject,"Spreading False Information about an Individual");
cv.put(Key_Description,"Whoever intentionally and publicly displays any" +
" information through any information system,"+
" which he knows to be false and intimidates or " +
"harms the reputation or privacy of a natural person.");
cv.put(Key_Panelty,"up to 3 Years in Prison or up to Rs. 1 Million in Fine or both");
db.insert(LAW_TABLE_NAME,null,cv);
Toast.makeText(c, "Data is inserted", Toast.LENGTH_SHORT).show();
db.close();
}
}
}
android.database.sqlite.SQLiteException:表Laws_Table没有 编译时,名为Category_name的列(代码1 SQLITE_ERROR): 插入 Laws_Table(类别名称,描述,类别,Sub_Category_name,主题,Panelty) 值(?,?,?,?,?,?)
答案 0 :(得分:-1)
您的SQL插入语句使用带有小写字母“ n”的“ Category_name”,但是您的create table语句使用大写字母“ N”创建带有“ Category_Name”的表。
请确保您使用的数据库API不考虑列名的大小写。有时查询需要区分大小写。让我知道这是否不能解决问题。