Thanks for quick answers guys!
It works very well with getCount(). Do you have any suggestions about
the query thou? Because it still returns 0 on get count when I try to
look for the already existing entry.
mCursor = mDb.query(true, RECENT_TABLE, new String[] {RECENT_ROWID,
RECENT_NAME, RECENT_FILE, RECENT_TIME}, RECENT_FILE + " = ?", new
String[]{file}, null, null, null, null);
Any suggestions there?
On Jan 29, 3:50 pm, kernelpanic <[email protected]> wrote:
> I just went through this myself, but my logic is inverted to yours, so
> ignore my previous
>
> probably better to use
>
> if (recentC.getCount() != 0) {
>
> On Jan 29, 8:41 am, André <[email protected]> wrote:
>
>
>
>
>
>
>
> > This is doing my head in.
> > I have a database where there is currently one entry. What I want to
> > do is to check if this entry exists. If it does I want to update it,
> > if not create a new one.
>
> > recentC = db.fetchExisting(file);
> > if (recentC != null){
> > long rwId =
> > recentC.getLong(recentC.getColumnIndexOrThrow(SilverDbManager.RECENT_ROWID)
> > );
> > db.updateRecent(rwId, name, file, time);} else {
>
> > db.createRecent(name, file, time);
>
> > }
>
> > public Cursor fetchExisting(String file) throws SQLException {
> > Cursor mCursor = null;
> > mCursor = mDb.query(true, RECENT_TABLE, new String[]
> > {RECENT_ROWID, RECENT_NAME, RECENT_FILE, RECENT_TIME}, RECENT_FILE + "
> > = ?", new String[]{file}, null, null, null, null);
> > return mCursor;
>
> > }
>
> > I know that recentC != null is probably wrong but I dont know what to
> > change it to. And its some problem with the query because it can't
> > find the entry I already have there when I search for it.
>
> > Any suggestions?
>
> > //André
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en