我在 m 注册活动中编写的这段代码,但它给了我错误 ANR 并且没有生成数据库
注册按钮上的此代码
SQLiteDatabase db = openOrCreateDatabase("RoseDetails",MODE_APPEND, null);
// db.execSQL("create table if not exists table_register(firstname VARCHAR(20),lastname VARCHAR(20),emailaddress VARCHAR(20),gender VARCHAR(20),password VARCHAR(20),confirmpassword VARCHAR(20)");
// db.execSQL("INSERT into table_student values('"+firstname.getText()+"','"+lastname.getText()+"','"+emailid.getText()+"','"+gendervaule+"','"+Pwd.getText()+"','"+"','"+cpwd.getText()+"')");
// Cursor c=db.rawQuery("SELECT * FROM table_register" , null);
// while(c.moveToNext())
// {
// if(c.moveToFirst())
// {
// String fn=c.getString(c.getColumnIndex("firstname"));
// String ln=c.getString(c.getColumnIndex("lastname"));
// String add=c.getString(c.getColumnIndex("emailaddress"));
// String g=c.getString(c.getColumnIndex("gender"));
// String p1=c.getString(c.getColumnIndex("password"));
// String p2=c.getString(c.getColumnIndex("confirmpassword"));
// Toast.makeText(this,"firstname"+fn+"\t"+"lastname"+ln+"\t"+"emailid"+add+"\t"+"gender"+g+"\t"+"pass"+p1+"\t"+"cpwd"+p2,Toast.LENGTH_LONG).show();
// }
// }
// c.close();
// db.close();
日志错误
11-24 08:01:00.163: W/dalvikvm(278): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-24 08:01:00.193: E/AndroidRuntime(278): FATAL EXCEPTION: main
11-24 08:01:00.193: E/AndroidRuntime(278): android.database.sqlite.SQLiteException: near ")": syntax error: create table if not exists table_register(firstname VARCHAR(20),lastname VARCHAR(20),emailaddress VARCHAR(20),gender VARCHAR(20),password VARCHAR(20),confirmpassword VARCHAR(20)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727)
11-24 08:01:00.193: E/AndroidRuntime(278): at com.example.orderplacemnet.Registration_Page.onClick(Registration_Page.java:158)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.view.View.performClick(View.java:2408)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.view.View$PerformClick.run(View.java:8816)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.os.Handler.handleCallback(Handler.java:587)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.os.Handler.dispatchMessage(Handler.java:92)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.os.Looper.loop(Looper.java:123)
11-24 08:01:00.193: E/AndroidRuntime(278): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-24 08:01:00.193: E/AndroidRuntime(278): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 08:01:00.193: E/AndroidRuntime(278): at java.lang.reflect.Method.invoke(Method.java:521)
11-24 08:01:00.193: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-24 08:01:00.193: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-24 08:01:00.193: E/AndroidRuntime(278): at dalvik.system.NativeStart.main(Native Method)