帮助我无法插入数据,但我的代码中没有任何错误,但在Logcat中,说“在sqliteDatabase中插入错误 很抱歉在One table中有很多专栏我是android开发中的新手 我按照这个链接 www.androiddevelopmentworld.blogspot.in/2013/04/android-sqlite-tutorial.html 我的完整项目CompleteSourceCode
logcat中的ScreenShot错误www.dropbox.com/sh/4656mj50d9fx6ch/toubkH2si0
public class DatabaseDental extends SQLiteOpenHelper{
public static final String ID="Id";
public static final String STUDID="Student_Id";
public static final String NAMES="Student_Name";
public static final String ADDRESS="Address";
public static final String AGE="Age";
public static final String SEX="Sex";
public static final String STATUS="Status";
public static final String CONTACT="Contact";
public static final String DATE="Date";
public static final String PROGRAM="Program";
public static final String DEPARTMENT="Department";
public static final String UP11="Upper_Eleven";
public static final String UP12="Upper_Twelve";
public static final String UP13="Upper_Thirteen";
public static final String UP14="Upper_Fourteen";
public static final String UP15="Upper_Fifteen";
public static final String UP16="Upper_Sixteen";
public static final String UP17="Upper_SevenTeen";
public static final String UP18="Upper_Eighteen";
public static final String UP21="Upper_Twentyone";
public static final String UP22="Upper_Twentytwo";
public static final String UP23="Upper_Twentythree";
public static final String UP24="Upper_Twentyfour";
public static final String UP25="Upper_Twentyfive";
public static final String UP26="Upper_Twentysix";
public static final String UP27="Upper_Twentyseven";
public static final String UP28="Upper_Twentyeight";
public static final String LOW41="Lower_Forthyone";
public static final String LOW42="Lower_Forthytwo";
public static final String LOW43="Lower_Forthythree";
public static final String LOW44="Lower_Forthyfour";
public static final String LOW45="Lower_Forthyfive";
public static final String LOW46="Lower_Forthysix";
public static final String LOW47="Lower_Forthyseven";
public static final String LOW48="Lower_Forthyeight";
public static final String LOW31="Lower_Thirtyone";
public static final String LOW32="Lower_Thirtytwo";
public static final String LOW33="Lower_Thirtythree";
public static final String LOW34="Lower_Thirtyfour";
public static final String LOW35="Lower_Thirtyfive";
public static final String LOW36="Lower_Thirtysix";
public static final String LOW37="Lower_Thirtyseven";
public static final String LOW38="Lower_Thirtyeight";
public static final String CALCULUS="Calculus";
public static final String DEBRIS="Debris";
public static final String CARRIES="Carries";
public static final String DEFORMITIES="Deformities";
public static final String GINGIVITIS="Gingivitis";
public static final String STAINS="Stains";
public static final String APPLIANCE="Appliance";
public static final String POCKET="Pocket";
public static final String PRESENT="Present";
public static final String FILLING="Filling";
public static final String EXTRACTION="Extraction";
public static final String FRAGMENT="Fragment";
public static final String MISSING="Missing";
public static final String FILLED="Filled";
public static final String DMF="Dmf";
private static final String NAME="DentalInfo";
private static final String TABLE="TeethFinding";
private ArrayList<DentalModel> cartList = new ArrayList<DentalModel>();
Context c;
public DatabaseDental(Context context) {
super(context, NAME, null, 33);
c = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE "+ TABLE +" (" +
ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + STUDID +
" TEXT," + NAMES + " TEXT," +ADDRESS + " TEXT," +
AGE + " TEXT," + SEX + " TEXT," +STATUS + " TEXT,"
+CONTACT + " TEXT," +
DATE + " TEXT," + PROGRAM + " TEXT," + DEPARTMENT +
" TEXT," +
UP11 + " TEXT,"+UP12 + " TEXT,"+UP13 + " TEXT,"+UP14 +
" TEXT,"+
UP15 + " TEXT,"+UP16 + " TEXT,"+UP17 + " TEXT,"+UP18 +
" TEXT,"+
UP21 + " TEXT,"+UP22 + " TEXT,"+UP23 + " TEXT,"+UP24 +
" TEXT,"+
UP25 + " TEXT,"+UP26 + " TEXT,"+UP27 + " TEXT,"+UP28 +
" TEXT,"+
LOW41 + " TEXT,"+LOW42 + " TEXT,"+LOW43 + " TEXT,"+LOW44 +
" TEXT,"+
LOW45 + " TEXT,"+LOW46 + " TEXT,"+LOW47 + " TEXT,"+LOW48 +
" TEXT,"+
LOW31 + " TEXT,"+LOW32 + " TEXT,"+LOW33 + " TEXT,"+LOW34 +
" TEXT,"+
LOW35 + " TEXT,"+LOW36 + " TEXT,"+LOW37 + " TEXT,"+
LOW38 +" TEXT,"+CALCULUS +" TEXT,"+DEBRIS +
" TEXT,"+CARRIES +" TEXT,"+
DEFORMITIES +" TEXT,"+GINGIVITIS +" TEXT,"+STAINS +
" TEXT,"+
APPLIANCE +" TEXT,"+POCKET +" TEXT,"+PRESENT +
" TEXT,"+FILLING +" TEXT,"+
EXTRACTION +" TEXT,"+FRAGMENT +" TEXT,"+MISSING +" TEXT,"+
FILLED +" TEXT,"+DMF+ " TEXT" + ")";
db.execSQL(CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS" + TABLE);
onCreate(db);
}
public void addDental(DentalModel dentalitem) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(STUDID, dentalitem.rstudentid);
cv.put(NAMES, dentalitem.rname);cv.put(ADDRESS, dentalitem.raddress);
cv.put(AGE, dentalitem.rage);cv.put(SEX, dentalitem.rsex);
cv.put(STATUS, dentalitem.rstatus);
cv.put(CONTACT, dentalitem.rcontact);
cv.put(DATE, dentalitem.rdates);cv.put(PROGRAM, dentalitem.rprogram);
cv.put(DEPARTMENT, dentalitem.rdepartment);
cv.put(UP11, dentalitem.rspin11);
cv.put(UP12, dentalitem.rspin12);cv.put(UP13, dentalitem.rspin13);
cv.put(UP14, dentalitem.rspin14);cv.put(UP15, dentalitem.rspin15);
cv.put(UP16, dentalitem.rspin16);
cv.put(UP17, dentalitem.rspin17);
cv.put(UP18, dentalitem.rspin18);cv.put(UP21, dentalitem.rspin21);
cv.put(UP22, dentalitem.rspin22);
cv.put(UP23, dentalitem.rspin23);
cv.put(UP24, dentalitem.rspin24);cv.put(UP25, dentalitem.rspin25);
cv.put(UP26, dentalitem.rspin26);
cv.put(UP27, dentalitem.rspin27);cv.put(UP28, dentalitem.rspin28);
cv.put( LOW41, dentalitem.rspin41);cv.put(LOW42, dentalitem.rspin42);
cv.put(LOW43, dentalitem.rspin43);
cv.put(LOW44, dentalitem.rspin44);cv.put(LOW45, dentalitem.rspin45);
cv.put(LOW46, dentalitem.rspin46);cv.put(LOW47, dentalitem.rspin47);
cv.put(LOW48, dentalitem.rspin48);
cv.put(LOW31, dentalitem.rspin31);
cv.put(LOW32, dentalitem.rspin32);cv.put(LOW33, dentalitem.rspin33);
cv.put(LOW34, dentalitem.rspin34);cv.put(LOW35, dentalitem.rspin35);
cv.put(LOW36, dentalitem.rspin36);
cv.put(LOW37, dentalitem.rspin37);cv.put(LOW38, dentalitem.rspin38);
cv.put(CALCULUS, dentalitem.rcal);
cv.put(DEBRIS, dentalitem.rdeb);cv.put(CARRIES, dentalitem.rcar);
cv.put(DEFORMITIES, dentalitem.rdef);
cv.put(GINGIVITIS, dentalitem.rgin);
cv.put(STAINS, dentalitem.rsta);cv.put(APPLIANCE, dentalitem.rapp);
cv.put(POCKET, dentalitem.rpoc);
cv.put(PRESENT, dentalitem.presents);
cv.put(FILLING, dentalitem.fillings);cv.put(EXTRACTION, dentalitem.extractions);
cv.put(FRAGMENT, dentalitem.fragments);
cv.put(MISSING, dentalitem.missings);cv.put(FILLED, dentalitem.filleds);
cv.put(DMF, dentalitem.dmfs);
db.insert(TABLE, null, cv);
db.close();
}
public ArrayList<DentalModel> getProudcts() {
cartList.clear();
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("select Student_id,
Student_Name, Program from TeethFinding", null);
if (cursor.getCount() != 0) {
if (cursor.moveToFirst()) {
do {
DentalModel item = new DentalModel();
item.rstudentid = cursor.getString(cursor
.getColumnIndex(STUDID));
item.rname = cursor.getString(cursor
.getColumnIndex(NAMES));
item.rprogram = cursor.getString(cursor
.getColumnIndex(PROGRAM));
cartList.add(item);
} while (cursor.moveToNext());
}
}
cursor.close();
db.close();
return cartList;
}
}