Can I use UNIQUE in the query() parameter?

by Bin Chen » Sun, 12 Apr 2009 20:51:58 GMT


Sponsored Links
 My contacts contain a lot of duplicated records, I want to use the
traditional SQL clause "UNIQUE" to get the unique records, is it
doable thru the query() method call? Thanks. I tried with the
selectionArgs argument but failed.

Bin
--~--~---------~--~----~------------~-------~--~----~



Can I use UNIQUE in the query() parameter?

by Mark Murphy » Sun, 12 Apr 2009 20:55:05 GMT


 


I am not aware of a UNIQUE clause in queries in SQL. There is DISTINCT
to get the unique records, and MySQL has a UNIQUE constraint in CREATE
TABLE and ALTER TABLE.

Regardless, you may want to try rawQuery() instead of query() -- I tend
to use that for things that are outside the ordinary.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books.html 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Is runtime mapview defining possible? (rather then in main.xml)

I've been trying to use a mapView in my app, and have been following
the tutorial;
http://developer.android.com/resources/tutorials/views/hello-mapview.html

However, I'd like to be able to generate the mapView at runtime, and
assign it to a widget container. (rather then just having it as the
route element in Main.xml as in the example).

Is this possible?

I tried just extending mapActivity as stated, and implementing the
overrides.
However, at the moment I'm getting this error;

"06-26 21:31:20.946: ERROR/AndroidRuntime(1845):
java.lang.IllegalAccessError: Class ref in pre-verified class resolved
to unexpected implementation
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
dalvik.system.DexFile.defineClass(Native Method)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
dalvik.system.DexFile.loadClassBinaryName(DexFile.java:209)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2489)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2621)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.app.ActivityThread.access$2200(ActivityThread.java:126)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.os.Handler.dispatchMessage(Handler.java:99)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.os.Looper.loop(Looper.java:123)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
android.app.ActivityThread.main(ActivityThread.java:4595)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
java.lang.reflect.Method.invokeNative(Native Method)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
java.lang.reflect.Method.invoke(Method.java:521)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-26 21:31:20.946: ERROR/AndroidRuntime(1845):     at
dalvik.system.NativeStart.main(Native Method)
"


Which I think might be because theres no where in my code or xml at
the moment that defines where the mapView actually goes.
I can't figure out how to assign it. (in this case to a page in my
tabHost)

-- 

2. Can I use Mozart's music in my Android apps/games

The answer is yes and no. The music itself is in the public domain, so if
you want to go to a recording studio and crank out Mozart on your violin,
you are in the clear. But when someone does their own recording, they own
the copyrights of their work. You would need to find a Mozart recording that
is in the public domain (I imagine you wouldn't have a problem here), either
because it was released this way or it is old enough to no longer have
attached copyrights.

Some other examples of this has to do with restored movies in the public
domain. The originals are in the public domain, but touch them up a bit and
you retain copyrights to the new work.





> 

3. Generate incoming SMS

4. Can I use Mozart's music in my Android apps/games

5. OpenGL works incorrectly when projection matrix is set to identity?

6. Moto Droid ADB Drivers no longer work after HTC Evo was used.

7. Unlimited XL lemot