[android-developers] Re: SQL query issue
you need single quotes around the pattern * 'select count(url) from bookmarks where url like \'www.android.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
[android-developers] Re: Sql query not working
Why Union All? Why not just a couple of ORs ? -- 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
Re: [android-developers] Re: Sql query not working
To make some DBAs cry? :P On Mon, Jul 25, 2011 at 7:55 PM, lbendlin l...@bendlin.us wrote: Why Union All? Why not just a couple of ORs ? -- 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
[android-developers] Re: SQL query
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
[android-developers] Re: SQL query
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
[android-developers] Re: SQL query
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 j.m.roya...@gmail.com 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é 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
Re: [android-developers] Re: SQL query
Your query looks ok to me. Check how you insert data, and make sure that the value that's stored in the database is what you expect. Oh, and before you call recentC.getLong(recentC.getColumnIndexOrThrow, make sure you've moved the cursor to the first row. -- Kostya 29.01.2011 18:02, André пишет: 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, kernelpanicj.m.roya...@gmail.com 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é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é -- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.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
[android-developers] Re: SQL query
Thanks, did as you said and found a mistake I made. It works perfectly now! On Jan 29, 4:14 pm, Kostya Vasilyev kmans...@gmail.com wrote: Your query looks ok to me. Check how you insert data, and make sure that the value that's stored in the database is what you expect. Oh, and before you call recentC.getLong(recentC.getColumnIndexOrThrow, make sure you've moved the cursor to the first row. -- Kostya 29.01.2011 18:02, André пишет: 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, kernelpanicj.m.roya...@gmail.com 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é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é -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.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
[android-developers] Re: sql query
Hi mahantesh, I am new to android. Can u guide me how to connect to database(Sqlite). For example if we take a login page it contains login and register buttons. in this i want to store username,password ,conform password,emailid and phone numbers. I designed all pages ,i am not able to access database and storing them I am waiting for ur reply Thanks and regards janardhan On Jul 22, 6:42 pm, mahantesh Hunagund mahantesh.t...@gmail.com wrote: Hi , I wanted to remove duplicates from the database. In my db duplication can be defined by combination of multiple columns. For example : _id kind type Pid name 1 1 1 3 aaa 2 1 2 3 aaa 3 1 1 3 aaa 4 2 1 3 aaa 5 4 1 4 bbb Here : combination of tuple kind and type make the uniqueness. For sample query : get the row for the pid =3 , query should return rows: 1,2,4 I can to use distinct clause in my sql query. Can anyone tell me how to specify distict clause in query provided by android content provider? I didn't understand selection and selectionArgs field for android query exposed by content provider. If I opt for writting rawQuery how to specify projection and URI ? Thanks, Mahantesh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: sql query
mahantesh Hunagund wrote: I wanted to remove duplicates from the database. In my db duplication can be defined by combination of multiple columns. For example : _id kind type Pidname 1 1 13 aaa 2 1 23 aaa 3 1 13 aaa 4 2 13 aaa 5 414 bbb Here : combination of tuple kind and type make the uniqueness. For sample query : get the row for the pid =3 , query should return rows: 1,2,4 I can to use distinct clause in my sql query. Can anyone tell me how to specify distict clause in query provided by android content provider? You can't. You cannot assume that a ContentProvider uses a SQL-compliant database for its storage. It might use flat files. It might use a db4o. It might use a cache for data retrieved off of a Web service. Hence, the syntax for the selection and selectionArgs is up to the provider. However, even for SQLite-backed providers, selection is simply the WHERE clause without the keyword WHERE, so you do not have access to the spot to put the DISTINCT keyword. If I opt for writting rawQuery how to specify projection and URI ? There is no rawQuery() option for ContentProvider, AFAIK. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: sql query
Do you need to use the content provider? Can't you access a database directly, or do you need to share the data? On 22 Juli, 15:42, mahantesh Hunagund mahantesh.t...@gmail.com wrote: Hi , I wanted to remove duplicates from the database. In my db duplication can be defined by combination of multiple columns. For example : _id kind type Pid name 1 1 1 3 aaa 2 1 2 3 aaa 3 1 1 3 aaa 4 2 1 3 aaa 5 4 1 4 bbb Here : combination of tuple kind and type make the uniqueness. For sample query : get the row for the pid =3 , query should return rows: 1,2,4 I can to use distinct clause in my sql query. Can anyone tell me how to specify distict clause in query provided by android content provider? I didn't understand selection and selectionArgs field for android query exposed by content provider. If I opt for writting rawQuery how to specify projection and URI ? Thanks, Mahantesh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: sql query
Kaj Bjurman wrote: Do you need to use the content provider? You were the one who brought up content providers. I have no idea what data, what database, or what content provider you are talking about. Can't you access a database directly If it is your database, yes. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: SQL Query
Cursor peopleCursor = contentResolver.query( Contacts.People.CONTENT_URI, new String[] {Contacts.People._ID, Contacts.People.DISPLAY_NAME}, // columns you want null, // WHERE selection null, // selection arguments Contacts.People._ID); // order by http://developer.android.com/reference/android/content/ContentResolver.html#query(android.net.Uri,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String) Yusuf Saib Android ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Jun 26, 2:06 am, M.Manjunatha man...@gmail.com wrote: Hi Folks, How do i select only one particular row sort by a column using a sqlite query in Android?? Regards, Manjunatha --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: SQL Query
Please throw some light on this.. On Tue, Jun 9, 2009 at 1:52 PM, M.Manjunatha man...@gmail.com wrote: Hi Folks, I have been given a requirement. Say you have five contacts in your phone book. Person1, Person2, Person3, Person4, Person5. You have received messages from the contacts.. Now that, I have to sort in the following manner. Initally, i have to sort in such a way that, I display one message per contact. The subsequent messages should be shown based on the timestamps. Please let me know how this can be achieved. -- Regards, Manjunatha --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: SQL Query
hi manju, be patient. if smone nos d ans 2 ur q, u'll get reply... till then try exploring other SQL specific groups since ur q may be addressed there better... On Wed, Jun 17, 2009 at 12:06 PM, Manjunatha M man...@gmail.com wrote: Please throw some light on this.. On Tue, Jun 9, 2009 at 1:52 PM, M.Manjunatha man...@gmail.com wrote: Hi Folks, I have been given a requirement. Say you have five contacts in your phone book. Person1, Person2, Person3, Person4, Person5. You have received messages from the contacts.. Now that, I have to sort in the following manner. Initally, i have to sort in such a way that, I display one message per contact. The subsequent messages should be shown based on the timestamps. Please let me know how this can be achieved. -- Regards, Manjunatha -- Regards, Sujay Mitch Hedberghttp://www.brainyquote.com/quotes/authors/m/mitch_hedberg.html - I drank some boiling water because I wanted to whistle. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---