Reputation: 54949
I have created SQLiteOpenHelper class to help me open write the database. but i am not able to invoke it from the main.java activity
I have created an Class which extends the Database Helper which is stored at
/Messaging/src/com/v3/messaging/DatabaseHelper.java
Code: http://pastebin.com/Z5qp32xu
now i have this class called Main.java which will be the first activity on the launch of the application. But how can i make the DatabaseHelper.java run just to create the database but still be at the Main.java file.
The database should be created with the tables only when the db or the tables dont exist.
Main.java code: http://pastebin.com/LVFVuhA0
Now when i run the program. the database is not being created :(
I am trying to learn Android. So please excuse me if i forgot to tell something.
Upvotes: 0
Views: 490
Reputation: 111
Harsha,
What exactly need to be done is, to create a object of the class DatabaseHelper in your main file. Once that is create, its constructor would be called resulting in the creation of the database and the tables in it. To put things inside these tables use ContentValues, you would find a lot of tutorial online for this.
Cuil
Upvotes: 1
Reputation: 28541
Nowhere in your activity you are creating the DB helper. You need to instanciate it so that the DB gets created. Try to get some tutorial about databases in Android first, there are plenty on the net. Also look at the SDK examples.
Upvotes: 1