Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:21:31+00:00 2026-06-13T03:21:31+00:00

I have create a class DatabaseInterface which will be used for Sqlite operations. DatabaseInterface.onCreate()

  • 0

I have create a class DatabaseInterface which will be used for Sqlite operations.
DatabaseInterface.onCreate() (where I have created a table) Method is not getting executed when i create an object of this class.

I have created object of DatabaseInterface in another class FirstTimeActivity

public class FirstTimeActivity extends Activity{

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    DatabaseInterface db = new DatabaseInterface(this);
    }
}

Below is class Definition of DatabaseInteface. The OnCreate() method is not getting executed, so my table is not getting created. The database has already been created.

public class DatabaseInterface  extends SQLiteOpenHelper{

    private static String       DB_NAME = "SMS_DB";
    private static int          DB_VERSION = 1;

    private String TABLE_NAME       = "SENT_ITEMS";
    private String COLUMN_ID        = "S_NO";
    private String COLUMN_MESSAGE   = "MESSAGE";
    private String COLUMN_DATETIME  = "DATE_TIME";

    //creates the database
    public DatabaseInterface(Context context) {
            super(context, DB_NAME, null, DB_VERSION);
            Log.d("Creating Database: ", "Creating Database");
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
            Log.d("Creating Table: ", "Creating Table");
            String create_table = "CREATE TABLE "+ TABLE_NAME + " ("+ COLUMN_ID +" INTEGER PRIMARY KEY, " + COLUMN_MESSAGE + " TEXT, " + COLUMN_DATETIME + "TEXT NOT NULL); ";
            db.execSQL(create_table);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    public void insertIntoDB(String message)
{
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();

    //get current date and time
    Calendar current_time = Calendar.getInstance();
    //current_time.getTime();
    String Cure = current_time.toString();
    Log.d("Current_Date_time: ", Cure);

    values.put(COLUMN_MESSAGE, message);
    values.put(COLUMN_DATETIME, "ad");

    db.insert("TEST", null, values);
    db.close(); // Closing database connection
}

};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:21:32+00:00Added an answer on June 13, 2026 at 3:21 am

    The database isn’t actually created until you call getWritableDatabase() on the DatabaseInterface object

    ** EDIT **

    With the new info it seems that the problem is that your DB is already created, hence the OS doesn’t need to execute the onCreate, as it’s already created. Either rethink how you are creating your DB to include table creation at the same time, or just insert the table manually if it doesn’t exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I intended to create a class which only have static members and static functions.
I want to create a Javascript class/object that allow me to have various method:
What tools have you used to create class source code from xml files? Is
I have create the class HoverButton which derives from Form.Button. Here I override the
Within my actor I have to create a class which sends a message to
I have to create an serializable class which has and xml in the format
I have to create a class that will load all the dll's from repository
I have create a class method that creating a Datasource on the fly in
I have create a Java class extending LinearLayout as shown below public class CustomLinear
I have create a Java class extending LinearLayout as shown below public class News

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.