Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Quick question about creating a database

Options
  • 03-06-2012 12:54pm
    #1
    Registered Users Posts: 5,949 ✭✭✭


    Hi, I'm creating my first java application - just messing around really. At what point is the database normally installed in an application - generally and in the case of a mobile application? Is it that during the application installation, extra code is run to create the database? Is there a good sample code for creating a database as I'm sure its fairly similiar for most simple applications? Thanks.


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Hi, I'm creating my first java application - just messing around really.
    I presume you mean native Android development, when you say Java. The following is specific only to that.
    At what point is the database normally installed in an application - generally and in the case of a mobile application? Is it that during the application installation, extra code is run to create the database?
    Not on installation, but when the app is run - specifically that part of the app code which creates the database is executed (note that this will also trigger the onUpgrade method that is used for schema up/downgrades).
    Is there a good sample code for creating a database as I'm sure its fairly similiar for most simple applications? Thanks.
    http://www.vogella.com/articles/AndroidSQLite/article.html
    http://www.drdobbs.com/mobile/232900584


  • Registered Users Posts: 5,949 ✭✭✭A Primal Nut


    Thanks; actually just doing a java program on Windows for now, but planning to start making it for Android as well so thats why I posted here.

    So basically, when the program is first opened, it checks to see if the database already exists, and if not, creates it.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Thanks; actually just doing a java program on Windows for now, but planning to start making it for Android as well so thats why I posted here.
    If you're doing this as a Java Windows application, then you be using a different library set, so a different process is involved.
    So basically, when the program is first opened, it checks to see if the database already exists, and if not, creates it.
    No, when the database is first opened, explicitly calling the getWritableDatabase method, this will trigger the SQLiteOpenHelper object's onCreate method to check if it exists, and if not, create it.


Advertisement