last day (15 days later) » 

6:50 PM
1
A: Why is my constructor not getting called?

Richard Le MesurierFirstly, the method SQLiteOpenHelper.onCreate() is not the constructor. I'm not sure, but it looks like you are mixing the 2 concepts up in the question. Now onto trying to solve the problem... It seems like your table is not being created. From the online help for SQLiteOpenHelper.onCreate()...

 
By "uninstall the app," do you mean on the emulator? If so, I don't know how that is done...?
 
yes, if you are developing on an emulator. The easiest way I find to uninstall is from command line, assuming the emulator is connected to adb: adb uninstall my.app.package.in.manifest (using the real app's real package name as declared in manifest)
by uninstalling, you remove the DB. When the database is needed next time you run it, the system will not find the database, and so it will call onCreate() for you.
 
Will it call ALL of the onCreate()s? I have a class that extends SQLiteOpenHelper for each table; should I just have one, wherein ALL the tables are created in the onCreate()?
Wouldn't that "uninstall" delete more than just the db? Could I simply go into Android Debug Monitor and manually delete the db file from there? That would seem more straightforward...?
 
hmmm, interesting question. As far as I understand it, the call to getWriteableDatabase() is what triggers the onCreate() or onUpgrade() callbacks. So by splitting your implementation across various helpers, this could be the reason for the problem. Having reread the documentation I linked to, I think its best to combine your various helper classes into a single one, or have them all inherit from a common base that creates all the tables.
hi, you there?
 
6:53 PM
ah hi
 
As to uninstalling, The most likely candidate I see in AndroidManifest.xml is:

android:label="@string/app_name"

If this is what you're talking about, then the adb command would be:

adb uninstall hhs

...correct?
 
Where the string is "HHS"
 
let me get the example ... its the package name in the manifest
 
app_name, that is
 
6:54 PM
eg:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mobi.glowworm.drinkthisin"
android:versionCode="4"
android:versionName="0.1.3" >

<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />
in my manifest it would be "package" up top there...
mobi.glowworm.drinkthisin
this is called the "manifest package", to avoid confusion with the normal java package structure (Android could have chosen a better name for this)
 
Okay, I have package="hhs.app"
 
cool
adb uninstall hhs.app
you'll see that this is how Android recognises your app
 
And that doesn't blow away the entire manifest file?
 
on Play store, and on the device
yes it will. let me think a sec
so normally, I would suggest a quick uninstall, but that's when there is nothing very useful stored in the app. I pick up some hesitation to totally uninstall and lose all your settings on the emulator, so in your case, it may be best to just delete the DB file
 
Okay, I'll try that, thanks.
 
6:57 PM
hence my suggestion to "blow away the entire" app
What we need to do in your case is to try to get the system to recreate that DB for you.
And hopefully you will be able to combine all those onCreate() methods into a single one
hope that helps
Where are you? I'm likely going offline in the next hour or so, and will be back in about 10 hours. Am in South Africa UTC +2.
but if you let me know the progress, I'll check back in tomorrow and see if I can help further
 
Thanks, I'm in California, and am leaving for the day.
 
ah ok, big time difference. I'll check back my tomorrow afternoon then and make sure you got yourself sorted out.
All the best
 

last day (15 days later) »