0

I have found numerous web references on how to use a SQLite database.

But everything I have found has the DatabaseHelper - onCreate() routine creating a Data Table.

I want to create an Empty SQLite Database (No Tables) and then add tables later on an as-need basis.

  1. Is it REQUIRED that 1 data table be added in order to Create a Database?
  2. When I have tried to utilize the openOrCreateDatabase() function in my DatabaseHelper class, it comes up as un-resolved.

Your advice/suggestions would be greatly appreciated.
Thanks

0

2 Answers 2

1

Is it REQUIRED that 1 data table be added in order to Create a Database?

You should be able to have a SQLiteOpenHelper that does nothing in onCreate().

Or, use openOrCreateDatabase() on SQLiteDatabase.

When I have tried to utilize the openOrCreateDatabase() function in my DatabaseHelper class, it comes up as un-resolved.

That is a static method on SQLiteDatabase, not SQLiteOpenHelper.

Sign up to request clarification or add additional context in comments.

Comments

0

What you suggest is doable, but I don't get the point of not initialising your database with the default system.

In any case, keep in mind:

  1. The onCreate method is not called until you don't get an instance of SQLiteDatabase from your SQLiteOpenHelper.
  2. You can always create new tables or execute any kind of query in your database using SQLiteDatabase#exeSQL

So to your question:

Is it REQUIRED that 1 data table be added in order to Create a Database

No, your database will be created the first time you get a reference to a SQLiteDatabase, for example calling to getWritableDatabase.

When I have tried to utilize the openOrCreateDatabase() function in my DatabaseHelper class, it comes up as un-resolved.

This method is more for internal use from the context. Use the open helper which is the preferred and recommended method.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.