I dont know whats wrong with this Code.. Is there is any Syntax error in creating table query??.. When i compile it throws. no such table.
public static final String DATABASE_NAME = "MMPDB.db";
// Table name definitions
public static final String LOG_IN_TABLE = "LogIn";
// LogIn table fields declaration
public static final String LOGIN_USERNAME = "userName";
public static final String LOGIN_PASSWORD = "password";
public static final String LOG_IN_TABLE_CREATE_QUERY = "CREATE TABLE "
+ LOG_IN_TABLE + " (" + LOGIN_USERNAME + " TEXT,"
+ LOGIN_PASSWORD + "TEXT);";
public MmpDBHelper(Context context) {
DATABASE_FILE_PATH = new File(Supporter.getAppCommonPath(),
DATABASE_NAME);
if (!DATABASE_FILE_PATH.exists()) {
try {
db = SQLiteDatabase.openOrCreateDatabase(DATABASE_FILE_PATH,
null);
// openDatabase();
db.beginTransaction();
db.execSQL(LOG_IN_TABLE_CREATE_QUERY);
db.setTransactionSuccessful();
Log.i("Success", "All tables created successfully");
} catch (Exception e) {
db.endTransaction();
errCode = "Error 501";
msg = "Table creation failed";
errMsg = errCode + " : " + msg;
LogFileCreator.appendLog(errMsg);
} finally {
// db.endTransaction();
db.close();
}
}
}
Aucun commentaire:
Enregistrer un commentaire