그래서 투표 애플리케이션으로 바쁘다. 등록한 사람의 주소 정보를 저장하기 위해 기존 데이터베이스에 테이블을 추가하려고 시도했지만 애플리케이션을 실행할 때 오류가 발생한다. 내 전화에서 어디에 로그인을 클릭하거나 버튼을 등록하면 응용 프로그램이 충돌하지만, 나는 로그 고양이를 사용하지만 새로운 시간 인 안드로이드 프로그래머이기 때문에 나는 내 오류를 모른다. 내가 오류는 이것이다 :기존 SQLite 데이터베이스에 테이블 추가하기
10-19 14:58:52.170 29644-29644/com.example.loginregisterwithsqlite E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.loginregisterwithsqlite, PID: 29644
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.loginregisterwithsqlite/com.example.loginregisterwithsqlite.LoginAndRegistrion}: android.database.sqlite.SQLiteException: near "tableADDRESS": syntax error (code 1): , while compiling: create tableADDRESS(ID integer primary key autoincrement,PROVINCE text,MUNICIPALITY text,STREET text,CITY text,FLAT text,TRIBE text,SUBURB text,TOWN text,POST text)
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(near "tableADDRESS": syntax error (code 1): , while compiling: create tableADDRESS(ID integer primary key autoincrement,PROVINCE text,MUNICIPALITY text,STREET text,CITY text,FLAT text,TRIBE text,SUBURB text,TOWN text,POST text))
#################################################################
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: android.database.sqlite.SQLiteException: near "tableADDRESS": syntax error (code 1): , while compiling: create tableADDRESS(ID integer primary key autoincrement,PROVINCE text,MUNICIPALITY text,STREET text,CITY text,FLAT text,TRIBE text,SUBURB text,TOWN text,POST text)
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(near "tableADDRESS": syntax error (code 1): , while compiling: create tableADDRESS(ID integer primary key autoincrement,PROVINCE text,MUNICIPALITY text,STREET text,CITY text,FLAT text,TRIBE text,SUBURB text,TOWN text,POST text))
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1005)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:570)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1976)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1907)
at com.example.loginregisterwithsqlite.DataBaseHelper.onCreate(DataBaseHelper.java:16)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.loginregisterwithsqlite.LoginDataBaseAdapter.open(LoginDataBaseAdapter.java:44)
at com.example.loginregisterwithsqlite.LoginAndRegistrion.onCreate(LoginAndRegistrion.java:38)
at android.app.Activity.performCreate(Activity.java:6912)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
... 9 more
다음과 같이 데이터베이스에 테이블에 삽입 내 코드는 다음과 같습니다
public class LoginDataBaseAdapter {
static final String DATABASE_NAME = "votersystem.db";
static final int DATABASE_VERSION = 1;
public static final int NAME_COLUMN = 4;
static final String CREATE_ADDRESS_TABLE = "create table"+"ADDRESS"+
"("+"ID integer primary key autoincrement,"+"PROVINCE text," +"MUNICIPALITY text,"+"STREET text,"+"CITY text,"+"FLAT text,"+"TRIBE text,"+"SUBURB text,"+"TOWN text,"+"POST text) ";
static final String CREATE_LOGIN_TABLE = "create table "+"LOGIN"+
"(" +"ID integer primary key autoincrement,"+"UNAME text," +"EMAIL text,"+"IDNUMBER text,"+"UPHONE text,"+"DIS text," +"PASSWORD text,"+"REPASSWORD text,"+ "SECURITYHINT text) ";
static final String CREATE_ADMIN_TABLE = "create table "+"ADMIN"+
"(" +"ID integer primary key autoincrement,"+ "FIRSTNAME text,"+"LASTNAME text,"+"PARTY text,"+ "SYMBOL text) ";
static final String CREATE_REPORT_TABLE = "create table "+"REPORT"+"(" +"ID integer primary key autoincrement,"+ "FULLNAME text,"+"PARTY text"+")";
public SQLiteDatabase db;
private final Context context;
private DataBaseHelper dbHelper;
private Cursor mCursor;
public LoginDataBaseAdapter(Context _context)
{
context = _context;
dbHelper = new DataBaseHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public LoginDataBaseAdapter open() throws SQLException
{
db = dbHelper.getWritableDatabase();
return this;
}
public void close()
{
db.close();
}
public SQLiteDatabase getDatabaseInstance()
{
return db;
}
public void insertEntry(String Prov, String Mun, String str, String cty, String flt, String trb, String sburb, String twn, String pst)
{
ContentValues newValues = new ContentValues();
newValues.put("PROVINCE",Prov);
newValues.put("MUNICIPALITY",Mun);
newValues.put("STREET",str);
newValues.put("CITY",cty);
newValues.put("FLAT",flt);
newValues.put("TRIBE",trb);
newValues.put("SUBURB",sburb);
newValues.put("TOWN",twn);
newValues.put("POST",pst);
db.insert("ADDRESS", null, newValues);
}
내 오류가에있는 CREATE_ADDRESS_TABLE
누군가가 나를 도울 수주십시오?
먼저 'table ADDRESS'로'tableADDRESS'를 변경해야합니다. ->' "테이블 생성"+ "ADDRESS"' – FlanschiFox