Code :
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
RegistrationPage var = new RegistrationPage();
DATABASE_TABLE = var.username.getText().toString();
db.execSQL(" CREATE TABLE " + DATABASE_TABLE + " (" + KEY_FIRSTNAME
+ " TEXT NOT NULL, " + KEY_MIDDLENAME
+ " TEXT NOT NULL, " + KEY_LASTNAME + " TEXT NOT NULL, " + KEY_USERNAME + " TEXT NOT NULL, " + KEY_MAIL_ID + " TEXT NOT NULL, " + KEY_DATE_OF_BIRTH + " INTEGER NOT NULL, " + KEY_COUNTRY + " TEXT NOT NULL " + ");");
The above code represents the method from DBAdapter class where i initialize and do all the activities in database.
I have 3 activities
- SignIn
- Register
- View
SignIn : Not concentrating on it as of now.
Register : In this page, i get the details of the user including the USERNAME WHICH SHOULD SET AS THE NAME FOR THE TABLE IN MY DATABASE. Then i open it and insert all the data into the database.
NOTE : Inserting the data doesn't work while i assign the table name dynamically but if i hardcode the table name then it works like a charm
View : While viewing, i need to open the database first which would require the table name that i assigned in the previous activity but it says null pointer exception while moving to this activity and force closes my application.
Help me guys. I am newbie and desperate about this project.