I'm very new to all of this so I greatly appreciate your advice.  But
to clarify, you mean instead of using AUTOINCREMENT i create a column
to hold an integer value that I set, and can therefore control rather
than let SQLite do it automatically?  This was what I was expecting to
have to do if there wasn't a work around.  I had read that deleting
the table row from the sqlite_sequence table would reset it, however,
this didn't seem to work for me.

On Nov 20, 10:11 am, Mark Murphy <mmur...@commonsware.com> wrote:
> JasonMP wrote:
> > I use a do/while that runs through one of my tables based on the
> > number of entries on another table and makes changes.
>
> > Example:
>
> > Integer i = 1;
>
> > Cursor c = db.querryFunction();
> > Integer rowCount = c.getCount();
>
> > do{
> >     //does work on the database
> >     db.updateRow(table, args, KEY_ROWID + "=" + i, null);
> >     i++;
> > }
> > while(i <= rowCount);
>
> > if my autoincrements skips numbers then I can get an error trying to
> > update a row that doesn't exist.
>
> I wouldn't recommend that structure in general. Making assumptions on
> the nature of primary keys always struck me as dangerous.
>
> AUTOINCREMENT is not going to be reliable for your situation, in any case:
>
> "Note that 'monotonically increasing' does not imply that the ROWID
> always increases by exactly one. One is the usual increment. However, if
> an insert fails due to (for example) a uniqueness constraint, the ROWID
> of the failed insertion attempt might not be reused on subsequent
> inserts, resulting in gaps in the ROWID sequence. AUTOINCREMENT
> guarantees that automatically chosen ROWIDs will be increasing but not
> that they will be sequential."
>
> (fromhttp://www.sqlite.org/autoinc.html)
>
> Personally, I'd avoid making the assumptions on the primary key values,
> and do your updates based on real primary keys. But, that's just me.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training in Germany, 18-22 January 2010:http://bignerdranch.com

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to