Message info
 
To:Android Developers From:Jeresam515 Subject:[android-developers] Why can\'t this database make rows? Date:Sun, 19 Feb 2012 13:18:33 -0800 (PST)
 

This database has been unable to make any rows as illustrated by the
fact that testcount always = 0.

Here is my variable initialization:
public static final String KEY_VALUE = "x";
public static final String KEY_ISROOT = "y";
public static final String KEY_ROWID = "_id";
public static final String KEY_REALROWID = "_ids";
public static final String KEY_ISPOWER = "z";
public static final String KEY_POWERORROOTNUMBER = "b";
public static final String KEY_ISDIVISOR = "a";
public static final String KEY_ISMULTIPLIER = "c";
public static final String KEY_ISADD = "d";
public static final String KEY_ISSUBTRACT = "e";
public static final String KEY_ISPS = "f";
public static final String KEY_ISPE = "g";
private static final String TAG = "NotesDbAdapter";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;
private static final String DATABASE_NAME = "data";
private static final String DATABASE_TABLE = "notes";
private static final int DATABASE_VERSION =20;
private static final String DATABASE_CREATE =
" create table " +DATABASE_TABLE+ " ("
+KEY_VALUE+ " double, "
+KEY_REALROWID+ " integer, "
+KEY_ROWID+ " integer primary key autoincrement, "
+KEY_ISPOWER+ " boolean, "
+KEY_ISDIVISOR+ " boolean, "
+KEY_ISMULTIPLIER+ " boolean, "
+KEY_ISADD+ " boolean, "
+KEY_ISSUBTRACT+ " boolean, "
+KEY_ISPS+ " boolean, "
+KEY_ISPE+ " boolean, "
+KEY_POWERORROOTNUMBER+ " double, "
+KEY_ISROOT+ " boolean);";

Here is the create row:
public void createNote(double value, boolean isroot, boolean ispower,
boolean ismultiply, boolean isdivisor, boolean add,
boolean issubtract, double roototpowerval, boolean
paranthaseesend, boolean paranthaseesstart) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_VALUE, value);
initialValues.put(KEY_ISROOT, isroot);
initialValues.put(KEY_ISPOWER, ispower);
initialValues.put(KEY_ISMULTIPLIER, ismultiply);
initialValues.put(KEY_ISDIVISOR, isdivisor);
initialValues.put(KEY_ISADD, add);
initialValues.put(KEY_ISSUBTRACT, issubtract);
initialValues.put(KEY_POWERORROOTNUMBER, roototpowerval);
initialValues.put(KEY_ISPE, paranthaseesend);
initialValues.put(KEY_ISPS, paranthaseesstart);
long r= mDb.insert(DATABASE_TABLE, null, initialValues);
int a = testCount();
ContentValues argsa = new ContentValues();
argsa.put(KEY_VALUE, value);
argsa.put(KEY_ISROOT, isroot);
argsa.put(KEY_ISPOWER, ispower);
argsa.put(KEY_ISMULTIPLIER, ismultiply);
argsa.put(KEY_ISDIVISOR, isdivisor);
argsa.put(KEY_ISADD, add);
argsa.put(KEY_ISSUBTRACT, issubtract);
argsa.put(KEY_POWERORROOTNUMBER, roototpowerval);
argsa.put(KEY_REALROWID, a);
argsa.put(KEY_ISPE, paranthaseesend);
argsa.put(KEY_ISPS, paranthaseesstart);
mDb.update(DATABASE_TABLE, argsa, KEY_ROWID + "=" + r, null);
}

Finally, here is testCount():
public int testCount() {
Cursor c = mDb.rawQuery("select count(*) from notes", null);
int tst = 0;
if (c.moveToNext()) {
tst = c.getInt(c.getColumnIndex("count(*)"));
}
return tst;
}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en