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é <pha...@hotmail.com> 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 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