I am currently building a password manager app for myself. I plan to save the passwords in a SQLite database. For that I use this code:
package com.example.passwordmanager;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import androidx.annotation.Nullable;
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String COLUMN_PASSWORD = "password";
public static final String PASSWORDS_TABLE = COLUMN_PASSWORD + "s_table";
public static final String COLUMN_ID = "id";
public static final String COLUMN_SERVICE = "service";
public static final String COLUMN_CREATION_DATE = "creation_date";
public static final String COLUMN_USED_NAME = "used_name";
public static final String COLUMN_USED_EMAIL = "used_email";
public DatabaseHelper(#Nullable Context context) {
super(context, "passwordManager.db", null,1);
Log.d("DatabaseHelper","Constructor reached");
}
#Override
public void onCreate(SQLiteDatabase db) {
String createTableStatement = "CREATE TABLE "+ PASSWORDS_TABLE + " ( " + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_SERVICE + " VARCHAR(40), " + COLUMN_PASSWORD + " VARCHAR(40), " + COLUMN_CREATION_DATE + " VARCHAR(11), " + COLUMN_USED_NAME + " VARCHAR(40), " + COLUMN_USED_EMAIL + " VARCHAR(40), master VARCHAR(20), firstTime BOOLEAN)";
Log.d("DatabaseHelper","OnCreate1 reached");
db.execSQL(createTableStatement);
Log.d("DatabaseHelper","OnCreate2 reached");
}
#Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS "+PASSWORDS_TABLE);
onCreate(db);
}
public boolean addToTable(Registration profile){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(COLUMN_PASSWORD,profile.hashedPassword);
cv.put(COLUMN_SERVICE,profile.service);
cv.put(COLUMN_CREATION_DATE,profile.creation_date);
cv.put(COLUMN_USED_NAME,profile.used_name);
cv.put(COLUMN_USED_EMAIL,profile.used_email);
long insert = db.insert(PASSWORDS_TABLE, null, cv);
if(insert==-1){
return true;
}else{
return false;
}
}
}
The problem with this code is, it just doesn't create the database or the folder of the database in data\data\com.example.passwordmanager. I tried outputting which methods it will reached when the constructor is called and I realized that it never reaches the onCreate method.
The DatabaseHelper class is only called once so for:
package com.example.passwordmanager;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.hardware.input.InputManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Toast;
public class CreatingNewEntryActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_creating_new_entry);
DatabaseHelper dh = new DatabaseHelper(CreatingNewEntryActivity.this);
}
Is this a problem with the code? Do I have to give permissions in the manifest.xml? Did I mess something up with the emulator? The App starts fine, it just doesn't create the database.
You need to call getWritableDatabase() or getReadableDatabase() on your database helper to make the framework create the database file and trigger onCreate(). Just calling the constructor is not enough.
See also: When is SQLiteOpenHelper onCreate() / onUpgrade() run?
Related
i have a problem to use a database in libGdx, for use this first i create this class:
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DataBaseHelper extends SQLiteOpenHelper {
public DataBaseHelper(Context context, String name,CursorFactory factory, int version)
{
super(context, name, factory, version);
}
#Override
public void onCreate(SQLiteDatabase _db)
{
_db.execSQL(DataBaseClass.DATABASE_RECORD);
}
#Override
public void onUpgrade(SQLiteDatabase _db, int _oldVersion, int _newVersion)
{
Log.w("TaskDBAdapter", "Upgrading from version " +_oldVersion + " to " +_newVersion + ", which will destroy all old data");
onCreate(_db);
}
}
and this class:
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Collections;
public class DataBaseClass {
static final String DATABASE_NAME = "my.database";
static final int DATABASE_VERSION = 1;
public static final int NAME_COLUMN = 1;
static final String DATABASE_RECORD = "create table "+"RECORD"+
"( " + "SCORE text, GAMES_PLAYED text); ";
public SQLiteDatabase db;
private final Context context;
private DataBaseHelper dbHelper;
public DataBaseClass(Context _context) {
context = _context;
dbHelper = new DataBaseHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public DataBaseClass open() throws SQLException {
db = dbHelper.getWritableDatabase();
return this;
}
public void close() {
db.close();
}
public SQLiteDatabase getDatabaseInstance() {
return db;
}
public void updateGamesPlayed(String game) {
ContentValues updatedValues = new ContentValues();
updatedValues.put("GAMES_PLAYED", game);
String where="GAMES_PLAYED = ?";
db.update("RECORD",updatedValues, where, new String[]{game});
}
public void updateBestScore(String score) {
ContentValues updatedValues = new ContentValues();
updatedValues.put("SCORE", score);
String where="SCORE = ?";
db.update("RECORD",updatedValues, where, new String[]{score});
}
}
but when i call the DataBaseClass in my principal class, which implement the interface Screen, i have problem here:
DBClass = new DataBaseClass(CONTEXT);
what is the context in this class? i try to use: "this", "getContext()", getActivity","this.getActivity", etc... but nothing works.
can someone help me?
Context here refers to your current class context you can simply pass this or principal.this
I have the following error
"/SQLiteLog﹕ (1) near "TABLEusers": syntax error
System.err﹕ android.database.sqlite.SQLiteException: near "TABLEusers": syntax error (code 1): , while compiling: CREATE TABLEusers(_id(INTEGER PRİMARY KEY AUTOINCREMENT ,u_nameTEXT NOT NULL,u_passTEXT NOT NULL);"
1023-1023/com.example.dogruprint.dogruprint2 E/SQLiteLog﹕ (1) near ")": syntax error
--------------------- DATABASE.java -------------------------------------
package com.example.dogruprint.dogruprint2;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;
import java.sql.SQLException;
public class Database {
public static final String KEY_ROWID = "_id";
public static final String KEY_NAME = "u_name";
public static final String KEY_PASS = "u_pass";
private static final String DB_NAME = "app";
private static final String DB_TABLE = "users";
private static final int version = 1;
private SQLiteDatabase ourDatabase;
private DBHelper ourHelper;
private Context ourContext;
private SQLiteDatabase writableDatabase;
public Database(Context context) {
ourContext = context;
}
public SQLiteDatabase getWritableDatabase() {
return writableDatabase;
}
public class DBHelper extends SQLiteOpenHelper {
public DBHelper(Context context)
{
super(context, DB_NAME, null, version);
}
#Override
public void onCreate(SQLiteDatabase db) {
/* db.execSQL("CREATE TABLE" + DB_TABLE + "("
+ KEY_ROWID + "(INTEGER PRIMARY KEY AUTOINCREMENT ,"
+ KEY_NAME + "TEXT NOT NULL,"
+ KEY_PASS + "TEXT NOT NULL);");
*/
String CREATE_USERS_TABLE = "CREATE TABLE " + DB_TABLE + "(" + KEY_ROWID +
" INTEGER PRIMARY KEY," + KEY_NAME + " TEXT," + KEY_PASS + " TEXT,"
+ ");";
db.execSQL(CREATE_USERS_TABLE);
}
#Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXIST" + DB_TABLE);
}
}
public Database open() throws SQLException {
ourHelper = new DBHelper(ourContext);
ourDatabase = ourHelper.getWritableDatabase();
return this;
}
public Database close() {
ourHelper.close();
return this;
}
public void addThat(String name, String pass) {
ContentValues cv = new ContentValues();
cv.put(KEY_NAME, name);
cv.put(KEY_PASS, pass);
ourDatabase.insert(DB_TABLE, null, cv);
}
}
------------------------------ siparisekle.java ----------------------------
package com.example.dogruprint.dogruprint2;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
import java.sql.SQLException;
import static android.R.*;
public class siparisekle extends Activity {
private AutoCompleteTextView act1, act2, act3;
private EditText edittxt1;
EditText etName,etPass;
TextView tvResult;
Button bSave;
Button bShow;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_siparisekle);
install_elements();
final Database db = new Database(this);
bSave.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
boolean ok = true;
String name = etName.getText().toString();
String pass = etPass.getText().toString();
try
{
db.open();
db.addThat(name, pass);
tvResult.setText(name + "Eklendi");
db.close();
}
catch (Exception e)
{
ok =false;
e.printStackTrace();
tvResult.setText("Sorun var");
}
finally
{
if(ok)
{
Dialog d =new Dialog(siparisekle.this);
TextView tv = new TextView(siparisekle.this);
tv.setText("BASARILI");
d.setTitle("Sonuç");
d.setContentView(tv);
d.show();
}
}
}
});
}
protected void install_elements()
{
etName = (EditText) findViewById(R.id.etName);
etPass= (EditText) findViewById(R.id.etPass);
tvResult= (TextView) findViewById(R.id.tvResult);
bSave= (Button) findViewById(R.id.bSave);
bShow= (Button) findViewById(R.id.bShow);
}
}
This was you problem
db.execSQL("CREATE TABLE" + DB_TABLE + "("
Then you fixed it
String CREATE_USERS_TABLE = "CREATE TABLE " + DB_TABLE + "(" ....
By adding the missing space.
But you have to remove the last comma here:
" TEXT,"
+ ");";
The semicolon is only useless, not harmful.
But the comma is an error and will cause problems.
But you didn't fix this:
db.execSQL("DROP TABLE IF EXIST" + DB_TABLE);
You need a space here too
db.execSQL("DROP TABLE IF EXIST " + DB_TABLE);
Anyway, now you have to uninstall and reinstall your app.
Create table query :
private static final String CREATE_TABLE = " CREATE TABLE " + TABLE_NAME + " ( " + UID + " INTEGER PRIMARY KEY AUTOINCREMENT , "
+ FNAME + " VARCHAR(255) , "
+ LNAME + " VARCHAR(255) ,"
+ PASSWORD + " text ,"
+ EMAIL + " VARCHAR(255) UNIQUE ,"
+ BIRTHDAY + " VARCHAR(255) ,"
+ GENDER + " VARCHAR(255) ,"
+ IMAGE + " text );";
I'm pretty sure you don't need the semi colon at the end your CREATE_USERS_TABLE String
I am creating an android application that has two databases. One is offline SQLite database directly on the device and another one on public server that is used for update the offline one.
This is the way I'm inserting data into my SQLite database:
My activity:
package com.empekapp;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
public class Linie extends Activity {
DBAdapter db
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.linie);
openDB();
}
private void openDB(){
db = new DBAdapter(this);
db.open();
db.insertLineRecord("1");
db.insertLineRecord("2");
}
And in my database adapter:
public static final String KEY_LINE_ROWID = "_id";
public static final String KEY_LINE_NAME = "line_name";
public static final int COL_LINE_ROWID = 0;
public static final int COL_LINE_NAME = 1;
public static final String[] ALL_LINE_KEYS = new String[] {KEY_LINE_ROWID, KEY_LINE_NAME};
private static final String TABLE_LINE = "lines";
private static final String TABLE_LINE_CREATE =
"create table if not exists " + TABLE_LINE + "("
+ KEY_LINE_ROWID + " integer primary key autoincrement, "
+ KEY_LINE_NAME + " VARCHAR not null unique);";
private final Context context;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBAdapter (Context ctx){
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper{
DatabaseHelper(Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
#Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(TABLE_LINE_CREATE);
}
#Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LINE);
}
}
public DBAdapter open(){
db = DBHelper.getWritableDatabase();
return this;
}
public void close(){
DBHelper.close();
}
public void insertLineRecord(String line_name){
db.execSQL("INSERT OR IGNORE INTO " + TABLE_LINE + "('"
+ KEY_LINE_NAME + "') VALUES ('"
+ line_name + "');");
}
Generally this solution is enough for me.. but data is inserted to the table everytime I'm opening that activity to prevent this I set the unique constraint but how to insert data only once, when I'm creating that table to avoid situation like this?
use the data insertion in onCreate of database adapter class as this will be called only once when database created by this you can make it insert only once and no need to unique constaraint as well
Like this:
public void onCreate(SQLiteDatabase db) {
db.execSQL(TABLE_LINE_CREATE);
db.insertLineRecord("1");
db.insertLineRecord("2");
}
I keep on getting this error saying that the table in my database doesn't exist but the table was declared.
So, I have this class to create appointments into a database, which is:
package com.example.calendar;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.EditText;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.example.calendar.Appointment;
import static com.example.calendar.Constants.KEY_DATE;
import static com.example.calendar.Constants.KEY_DETAILS;
import static com.example.calendar.Constants.KEY_ID;
import static com.example.calendar.Constants.KEY_TIME;
import static com.example.calendar.Constants.KEY_TITLE;
import static com.example.calendar.Constants.TABLE_APP;
public class CreateAppointment extends Activity implements OnClickListener{
EditText titleTextBox, timeTextBox, detailsTextBox;
int[] dateSelected = new int[3];
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create);
titleTextBox = (EditText) findViewById(R.id.apptTitle);
timeTextBox = (EditText) findViewById(R.id.apptTime);
detailsTextBox = (EditText) findViewById(R.id.apptDetails);
View createButton = (Button) findViewById(R.id.apptSave);
String dateToPass = null;
Bundle getExtraFromMain = getIntent().getExtras();
if(getExtraFromMain != null){
dateSelected = getExtraFromMain.getIntArray(dateToPass);
}
createButton.setOnClickListener(this);
}
private Cursor cursor(){
DBHandler appointment = new DBHandler(this);
SQLiteDatabase db = appointment.getReadableDatabase();
String[] getValueFrom = {KEY_DATE, KEY_TITLE, KEY_TIME, KEY_DETAILS};
Cursor cursor = db.query(TABLE_APP, getValueFrom, null, null, null, null, KEY_DATE + " ASC");
return cursor;
}
private void save(){
String getTime = timeTextBox.getText().toString();
String getTitle = titleTextBox.getText().toString();
String getDetails = detailsTextBox.getText().toString();
DBHandler appointment = new DBHandler(this);
SQLiteDatabase db = appointment.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_TITLE, getTitle);
values.put(KEY_TIME, getTime);
values.put(KEY_DETAILS, getDetails);
values.put(KEY_DATE, dateSelected[0] + "/" + dateSelected[1] + "/" + dateSelected[2]);
db.insertOrThrow(TABLE_APP, null, values);
appointment.close();
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.apptSave:
save();
finish();
break;
}
}
}
And, of course, my handler:
package com.example.calendar;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import static com.example.calendar.Constants.KEY_DATE;
import static com.example.calendar.Constants.KEY_DETAILS;
import static com.example.calendar.Constants.KEY_ID;
import static com.example.calendar.Constants.KEY_TIME;
import static com.example.calendar.Constants.KEY_TITLE;
import static com.example.calendar.Constants.TABLE_APP;
public class DBHandler extends SQLiteOpenHelper {
//Variables needed
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "appts.db";// database name
public DBHandler(Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
#Override//create table
public void onCreate(SQLiteDatabase db){
String CREATE_APPOINTMENTS_TABLE = "CREATE TABLE " + TABLE_APP + " ("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_DATE + " TEXT NOT NULL,"
+ KEY_TITLE + " TEXT NOT NULL, " + KEY_TIME + " TEXT NOT NULL, " + KEY_DETAILS + " TEXT NOT NULL" + ");";
db.execSQL(CREATE_APPOINTMENTS_TABLE);
}
#Override//when upgraded, trigger
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
db.execSQL("DROP TABLE IF EXISTS " + TABLE_APP);//delete table from older version
onCreate(db);//create new table
}
}
And additionally, the interface where the table name was declared:
package com.example.calendar;
import android.provider.BaseColumns;
public interface Constants extends BaseColumns{
public static final String TABLE_APP = "appointments";// table name
public static final String KEY_ID = "id";
public static final String KEY_DATE = "date";
public static final String KEY_TITLE = "title";
public static final String KEY_TIME = "time";
public static final String KEY_DETAILS = "details";
}
When I hit the button on the Activity, Logcat gives me this:
03-24 02:18:28.134: E/AndroidRuntime(800): android.database.sqlite.SQLiteException: no such table: appointments: , while compiling: INSERT INTO appointments(time,title,date,details) VALUES (?,?,?,?)
03-24 02:18:28.134: E/AndroidRuntime(800): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
03-24 02:18:28.134: E/AndroidRuntime(800): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
03-24 02:18:28.134: E/AndroidRuntime(800): at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:112)
03-24 02:18:28.134: E/AndroidRuntime(800): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1718)
03-24 02:18:28.134: E/AndroidRuntime(800): at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1617)
03-24 02:18:28.134: E/AndroidRuntime(800): at com.example.calendar.CreateAppointment.save(CreateAppointment.java:69)
03-24 02:18:28.134: E/AndroidRuntime(800): at com.example.calendar.CreateAppointment.onClick(CreateAppointment.java:80)
Note: lines 69 and 80 are:
69:
db.insertOrThrow(TABLE_APP, null, values);
80:
save();//from switch statement
Can someone please help me??
Your code look fine, so changing the DATABASE_VERSION = 1 to DATABASE_VERSION = 2 may do the trick.
The reason because the onCreate() and onUpgrade() run only once! Therefore if you did any change within them after calling them, the change will not take affect. So changing the VERSION of the database or clearing your application data in your device/emulator could trigger to run the onCreate() and onUpgrade() again.
So whenever you change anything within the onCreate() and onUpgrade() increase the Database version.
Kohli.java
package com.kohli;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.content.Context;
public class KohlifActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("KOHLIActivity", "qwert11111111");
setContentView(R.layout.main);
Log.i("KOHILActivity", "qwert22222222222");
DbHelper1 DbHelper=new DbHelper1(this) ;
Log.i("KOHLIfActivity", "qwert3333333333");
}
}
DbHelper1.java
package com.kohli;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;
public class DbHelper1 extends SQLiteOpenHelper
{
static final String TAG = "DbHelper1";
static final String DB_NAME = "timeline.db";
static final int DB_VERSION = 1;
static final String TABLE = "timeline";
static final String C_ID = BaseColumns._ID;
static final String C_CREATED_AT = "created_at";
static final String C_SOURCE = "source";
static final String C_TEXT = "txt";
static final String C_USER = "user";
Context context;
public DbHelper1(Context context) {
super(context, DB_NAME, null, DB_VERSION);
this.context = context;
Log.d(TAG, "constructor111111");
//System.out.println("dbhelper constructor");
}
// Called only once, first time the DB is created
public void onCreate(SQLiteDatabase db) {
String sql = "create table " + TABLE + " (" + C_ID + " int primary key, "
+ C_CREATED_AT + " int, " + C_USER + " text, " + C_TEXT + " text)";
db.execSQL(sql);
Log.d(TAG, "onCreated sql:22222222 ");
//System.out.println("dbhelper oncreate");
}
// Called whenever newVersion != oldVersion
#Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Typically do ALTER TABLE statements, but...we're just in development,
// so:
db.execSQL("drop table if exists " + TABLE); // drops the old database
Log.d(TAG, "onUpdated 33333333");
//System.out.println("dbhelper onupgrade");
onCreate(db); // run onCreate to get new database
}
}
i wrote the following code to make a database with a table... the output at logcat is :: qwert111111 qwert22222 constructor111111 qwert3333 .. that is the oncreate function is not being called so the database is also not created...
The database isn't actually created until you call getWritableDatabase() on the
dbHelper object.