my Database won't insert
<p>I've done this same kind of thing in another app and it works fine. But taking the bits of code I needed from that app has not worked out. No matter how many times I look at it I can't see what I've done wrong. I'm someone here can point out where I've gone wrong.</p>

<h2>sqlite db adapter</h2>

<pre><code>public class triDbAdapter {




private static final String TAG = "dbAdapter";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;
private final Context mCtx;

private static class DatabaseHelper extends SQLiteOpenHelper {

    DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }



    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL(DATABASE_CREATE1);
        db.execSQL(DATABASE_CREATE2);
        db.execSQL(DATABASE_CREATE3);


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                + newVersion + ". ALL data will be destroyed");
        db.execSQL("DROP TABLE IF EXISTS user");
        db.execSQL("DROP TABLE IF EXISTS games");
        db.execSQL("DROP TABLE IF EXISTS tilesPlayed");
        onCreate(db); 

    }

}    

/**
 * Constructor - takes the context to allow the database to be
*/
public  triDbAdapter(Context ctx) {
    this.mCtx = ctx;
}

/**
 * 
 */
public triDbAdapter open() throws SQLException {
    mDbHelper = new DatabaseHelper(mCtx);
    mDb = mDbHelper.getWritableDatabase();
    return this;
}

public void close() {
    mDbHelper.close();
}

/**
 * createUserProfile inserts the local username and server-generated userid, _ID , into the database.
 */

public long createUserProfile(String username, int _id) {
    ContentValues initialValues = new ContentValues();
    initialValues.put(KEY_NAME, username);
    initialValues.put(KEY_USERID, _id);

    return mDb.insert(PLAYER_TABLE, null, initialValues);
}
</code></pre>

<h2>Activity</h2>

<pre><code>public class game extends Activity {

private EditText mNameText;  // username
private String userName;
private int userId;
private Context mCtx;
private ServerCommunication sComm;
private Boolean good_to_go;
private triDbAdapter mDbHelper;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    mCtx = this;
    mDbHelper = new triDbAdapter(this);
    mDbHelper.open();

    sComm = new ServerCommunication();
    good_to_go = false;

    setContentView(R.layout.initial_form);

    mNameText = (EditText) findViewById(R.id.username);
    Button submitButton = (Button) findViewById(R.id.submit);
    submitButton.setOnClickListener(doIt);


}

private OnClickListener doIt = new OnClickListener() {
    public void onClick(View v) {

        userName = mNameText.getText().toString();
        if (userName.isEmpty()) {
            Toast.makeText(mCtx, "need a name here.", Toast.LENGTH_SHORT).show();
        }
        else {
            try {
                userId = sComm.registerUser(mCtx,userName);
                if (userId &gt; 0) {
                    // returns true - we're good to go!
                    Toast.makeText(mCtx, "Congratulations! You're ready to play Tri-Ominoes", Toast.LENGTH_SHORT).show();
                    good_to_go = true;
                    Long ret = mDbHelper.createUserProfile(userName,userId);
                    if (ret == 0) {
                        //
                    }
                }
                else {
                    // the only error we could get is duplicate name
                    Toast.makeText(mCtx, "Sorry, username:" + userName +" already exists. Try another name.", Toast.LENGTH_SHORT).show();
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }

};
</code></pre>

<p>}</p>

<p>I get the username from the edittext and then I call a HTTP function which parses some JSON data that comes back from a server. 
That all comes back ok, but when I try to insert it in the database and create
and user profile it fails. The database is available and created - I can pull it off the emulator and read it with Sqlite databrowser but the tables are there, just empty.</p>

<p>Any ideas what I've done wrong here?  I've got a feeling this is something simple and a real forehead slapper.  Feel free to abuse me if it is. :)user</p>
