gpt4 book ai didi

android - SQLite DatabaseUtils.queryNumEntries 不适用于真实设备,但适用于模拟器

转载 作者:IT王子 更新时间:2023-10-29 06:28:43 24 4
gpt4 key购买 nike

我正在使用以下方法计算我的行数

long numRows = DatabaseUtils.queryNumEntries(ourDatabase, "fuel_table");

和列中的条目

 long mileagenum = DatabaseUtils.queryNumEntries(ourDatabase, FUEL_DATABASE_TABLE, KEY_MILEAGE);

这两种方法在模拟器上都可以正常工作,但在真实设备上会出错...

知道出了什么问题吗?谢谢。

我得到一个错误日志:-

java.lang.NoSuchMethodError: android.database.DatabaseUtils.queryNumEntries
at com.poojag.fuelcheck.FuelStoredInfo.getAvgMileage(FuelStoredInfo.java:252)
at com.poojag.fuelcheck.Prediction.onFocusChange(Prediction.java:199)
at android.view.View.onFocusChanged(View.java:2742)
at android.widget.TextView.onFocusChanged(TextView.java:6957)
at android.view.View.handleFocusGainInternal(View.java:2565)
at android.view.View.requestFocus(View.java:3720)
at android.view.View.requestFocus(View.java:3671)
at android.view.View.requestFocus(View.java:3649)
at android.view.View.onTouchEvent(View.java:4445)
at android.widget.TextView.onTouchEvent(TextView.java:7130)
at android.widget.EditText.onTouchEvent(EditText.java:143)
at android.view.View.dispatchTouchEvent(View.java:3885)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1750)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1135)
at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1734)
at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2216)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)

最佳答案

queryNumEntries with selection在 API 级别 11 中引入。您的 2.3.6 设备正在运行 API 级别 10。

您可以将其替换为常规的COUNT(*) 选择查询,例如:

long mileagenum = DatabaseUtils.longForQuery(ourDatabase,
"SELECT COUNT(*) FROM " + FUEL_DATABASE_TABLE + " WHERE " + KEY_MILEAGE, null);

关于android - SQLite DatabaseUtils.queryNumEntries 不适用于真实设备,但适用于模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18253297/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com