ContentProvider中使用DISTINCT

被各种坑之后写下这篇博客  

今天下午查数据的时候 发现有各种重复数据   自然想到了sql里面的DISTINCT关键字  但这是在ContentProvider中 刚开始木找到正确的做法  于是各种google 各种百度  得到的答案是在   query(uri, projection, selection, selectionArgs, orderBy);  里面的projection里面拼distinct     new String[]{"DISTINCT xxx"}   

 我试过了 但是只是在projection里面只有一个参数的时候有效   多个参数的时候会报 java.lang.IllegalArgumentException: Invalid column  distinct xxx  这个错误 

不知道是我的原因还是本身就不行  看 stackoverflow  这里面介绍的也是用这种方法   

我就各种无语了...尼玛这个问题就没解决吗... 关于这个问题 正确 有效的解决方法 网上还没找到... 我了个擦  

然后继续找  突然想到 会不会在query方法里面有解决办法. 

设置之后 (传入的projection 不用加 distinct  )  就好使了.... 好无语...

<?xml version="1.0" encoding="utf-8" standalone="no"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" compileSdkVersion="36" compileSdkVersionCodename="16" package="com.AAA.Fish" platformBuildVersionCode="36" platformBuildVersionName="16"> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true"/> <application android:banner="@drawable/app_banner" android:debuggable="true" android:icon="@drawable/app_icon" android:isGame="true" android:label="@string/app_name" android:theme="@style/UnityThemeSelector"> <activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="fullSensor"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <meta-data android:name="unityplayer.UnityActivity" android:value="true"/> <meta-data android:name="URL_VALUE" android:value="http://192.168.2.169"/> <meta-data android:name="CHANNEL" android:value="AgentID-0"/> <meta-data android:name="FW_VALUE" android:value="FW-30855784"/> <meta-data android:name="AppID" android:value="wx401c37330dd3e92e"/> </activity> </application> <uses-feature android:glEsVersion="0x20000"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:maxSdkVersion="18" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-feature android:name="android.hardware.touchscreen" android:required="false"/> <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/> <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false"/> </manifest> 帮我修复
最新发布
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值