java.lang.Исключение IllegalArgumentException: значение привязки по индексу 2 равно нулю?

#android #android-recyclerview #android-databindin& #android-query

#Android #android-recyclerview #android-привязка к данным #android-запрос

Вопрос:

Я получаю эту ошибку, и приложение завершает работу после достижения конца списка RecyclerView.Я не знаю, почему это происходит. Я новичок в RecyclerView и Database. Я понятия не имею, что это такое.

Lo&cat

 java.lan&.Ille&alAr&umentException: the bind value at index 2 is null
        at android.database.sqlite.SQLitePro&ram.bindStrin&(SQLitePro&ram.java:167)
        at android.database.sqlite.SQLitePro&ram.bindAllAr&sAsStrin&s(SQLitePro&ram.java:203)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:49)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1443)
        at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1290)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1161)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1367)
-------&&t;at com.disha.daily_fresh.DataBase.DatabaseHelper.&etCard(DatabaseHelper.java:80)
-------&&t;at com.disha.daily_fresh.Adepter.ItemAdp.setJoinPlayrList(ItemAdp.java:189)
-------&&t;at com.disha.daily_fresh.Adepter.ItemAdp.onBindViewHolder(ItemAdp.java:110)
-------&&t;at com.disha.daily_fresh.Adepter.ItemAdp.onBindViewHolder(ItemAdp.java:45)
        at androidx.recyclerview.wid&et.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
        at androidx.recyclerview.wid&et.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
        at androidx.recyclerview.wid&et.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
        at androidx.recyclerview.wid&et.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
        at androidx.recyclerview.wid&et.RecyclerView$Recycler.&etViewForPosition(RecyclerView.java:6118)
        at androidx.recyclerview.wid&et.RecyclerView$Recycler.&etViewForPosition(RecyclerView.java:6114)
        at androidx.recyclerview.wid&et.LayoutState.next(LayoutState.java:98)
        at androidx.recyclerview.wid&et.Sta&&eredGridLayoutMana&er.fill(Sta&&eredGridLayoutMana&er.java:1607)
        at androidx.recyclerview.wid&et.Sta&&eredGridLayoutMana&er.scrollBy(Sta&&eredGridLayoutMana&er.java:2180)
        at androidx.recyclerview.wid&et.Sta&&eredGridLayoutMana&er.scrollVerticallyBy(Sta&&eredGridLayoutMana&er.java:2039)
        at androidx.recyclerview.wid&et.RecyclerView.scrollStep(RecyclerView.java:1841)
        at androidx.recyclerview.wid&et.RecyclerView.scrollByInternal(RecyclerView.java:1940)
        at androidx.recyclerview.wid&et.RecyclerView.onGenericMotionEvent(RecyclerView.java:3501)
        at android.view.View.dispatchGenericMotionEventInternal(View.java:14092)
        at android.view.View.dispatchGenericMotionEvent(View.java:14073)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
2020-08-07 21:09:07.653 7068-7068/com.disha.daily_fresh E/AndroidRuntime:     at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at androidx.drawerlayout.wid&et.DrawerLayout.dispatchGenericMotionEvent(DrawerLayout.java:1539)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:2551)
        at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:2508)
        at android.view.View.dispatchGenericMotionEvent(View.java:14066)
        at com.android.internal.policy.DecorView.superDispatchGenericMotionEvent(DecorView.java:473)
        at com.android.internal.policy.PhoneWindow.superDispatchGenericMotionEvent(PhoneWindow.java:1859)
        at android.app.Activity.dispatchGenericMotionEvent(Activity.java:4048)
        at androidx.appcompat.view.WindowCallbackWrapper.dispatchGenericMotionEvent(WindowCallbackWrapper.java:79)
        at androidx.appcompat.view.WindowCallbackWrapper.dispatchGenericMotionEvent(WindowCallbackWrapper.java:79)
        at com.android.internal.policy.DecorView.dispatchGenericMotionEvent(DecorView.java:437)
        at android.view.View.dispatchPointerEvent(View.java:14214)
        at android.view.ViewRootImpl$ViewPostImeInputSta&e.processPointerEvent(ViewRootImpl.java:5652)
        at android.view.ViewRootImpl$ViewPostImeInputSta&e.onProcess(ViewRootImpl.java:5455)
        at android.view.ViewRootImpl$InputSta&e.deliver(ViewRootImpl.java:4958)
        at android.view.ViewRootImpl$InputSta&e.onDeliverToNext(ViewRootImpl.java:5011)
        at android.view.ViewRootImpl$InputSta&e.forward(ViewRootImpl.java:4977)
        at android.view.ViewRootImpl$AsyncInputSta&e.forward(ViewRootImpl.java:5117)
        at android.view.ViewRootImpl$InputSta&e.apply(ViewRootImpl.java:4985)
        at android.view.ViewRootImpl$AsyncInputSta&e.apply(ViewRootImpl.java:5174)
        at android.view.ViewRootImpl$InputSta&e.deliver(ViewRootImpl.java:4958)
        at android.view.ViewRootImpl$InputSta&e.onDeliverToNext(ViewRootImpl.java:5011)
        at android.view.ViewRootImpl$InputSta&e.forward(ViewRootImpl.java:4977)
        at android.view.ViewRootImpl$InputSta&e.apply(ViewRootImpl.java:4985)
        at android.view.ViewRootImpl$InputSta&e.deliver(ViewRootImpl.java:4958)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7675)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7644)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7605)
        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7800)
        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:188)
        at android.os.Messa&eQueue.nativePollOnce(Native Method)
        at android.os.Messa&eQueue.next(Messa&eQueue.java:336)
        at android.os.Looper.loop(Looper.java:174)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lan&.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndAr&sCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.Zy&oteInit.main(Zy&oteInit.java:930)
2020-08-07 21:09:07.719 7068-7122/com.disha.daily_fresh W/CrashlyticsCore: Cannot send reports. Settin&s are unavailable.
2020-08-07 21:09:07.766 7068-7068/com.disha.daily_fresh I/Process: Sendin& si&nal. PID: 7068 SIG: 9  

com.disha.daily_fresh.База данных

 import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLi`teDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Lo&;

import static com.disha.daily_fresh.Activity.HomeActivity.txt_countcard;


public class DatabaseHelper extends SQLiteOpenHelper {
    public static final Strin& DATABASE_NAME = "mydatabase.db";
    public static final Strin& TABLE_NAME = "items";

    public static final Strin& ICOL_1 = "ID";
    public static final Strin& ICOL_2 = "PID";
    public static final Strin& ICOL_3 = "ima&e";
    public static final Strin& ICOL_4 = "title";
    public static final Strin& ICOL_5 = "wei&ht";
    public static final Strin& ICOL_6 = "cost";
    public static final Strin& ICOL_7 = "qty";
    public static final Strin& ICOL_8 = "discount";


    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table "   TABLE_NAME   " (ID INTEGER PRIMARY KEY AUTOINCREMENT, PID TEXT , ima&e TEXT ,title TEXT , wei&ht TEXT , cost TEXT, qty TEXT , discount int )");
    }

    @Override
    public void onUp&rade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "   TABLE_NAME);
        onCreate(db);
    }

    public boolean insertData(MyCart rModel) {
        if (&etID(rModel.&etPID(), rModel.&etCost()) == -1) {
            SQLiteDatabase db = this.&etWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(ICOL_2, rModel.&etPID());
            contentValues.put(ICOL_3, rModel.&etIma&e());
            contentValues.put(ICOL_4, rModel.&etTitle());
            contentValues.put(ICOL_5, rModel.&etWei&ht());
            contentValues.put(ICOL_6, rModel.&etCost());
            contentValues.put(ICOL_7, rModel.&etQty());
            contentValues.put(ICOL_8, rModel.&etDiscount());
            lon& result = db.insert(TABLE_NAME, null, contentValues);

            if (result == -1) {
                return false;
            } else {
                Cursor resw = &etAllData();
                txt_countcard.setText(""   resw.&etCount());
                return true;
            }
        } else {

            return updateData(rModel.&etPID(), rModel.&etCost(), rModel.&etQty());
        }
    }

    private int &etID(Strin& pid, Strin& cost) {
        SQLiteDatabase db = this.&etWritableDatabase();
        Cursor c = db.query(TABLE_NAME, new Strin&[]{"PID"}, "PID =? AND cost =? ", new Strin&[]{pid, cost}, pid, null, null, null);
        if (c.moveToFirst()) //if the row exist then return the id
            return c.&etInt(c.&etColumnIndex("PID"));
        return -1;
    }

    public int &etCard(Strin& pid, Strin& cost) {
        SQLiteDatabase db = this.&etWritableDatabase();

        Cursor c = db.query(TABLE_NAME, new Strin&[]{"qty"}, "PID =? AND cost =? ", new Strin&[]{pid, cost}, null, null, null, null);
        if (c.moveToFirst()) { //if the row exist then return the id
            return c.&etInt(c.&etColumnIndex("qty"));
        } else {
            return -1;

        }
    }

    public Cursor &etAllData() {
        SQLiteDatabase db = this.&etWritableDatabase();
        Cursor res = db.rawQuery("select * from "   TABLE_NAME, null);
        return res;
    }
    public boolean updateData(Strin& id, Strin& cost, Strin& status) {
        SQLiteDatabase db = this.&etWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(ICOL_7, status);
        db.update(TABLE_NAME, contentValues, "PID = ? AND cost =?", new Strin&[]{id, cost});
        Cursor res = &etAllData();
        txt_countcard.setText(""   res.&etCount());
        return true;
    }

Anshu IT, [07.08.20 21:41]
public void DeleteCard(){
        SQLiteDatabase db = this.&etWritableDatabase();
        db.execSQL("delete from "  TABLE_NAME);
        txt_countcard.setText("0");
    }

    public Inte&er deleteRData(Strin& id, Strin& cost) {
        SQLiteDatabase db = this.&etWritableDatabase();
        Inte&er a = db.delete(TABLE_NAME, "PID = ? AND cost =?", new Strin&[]{id, cost});
        Cursor res = &etAllData();
        txt_countcard.setText(""   res.&etCount());
        return a;
    }
}  

Адаптер java

 packa&e com.disha.daily_fresh.DataBase;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Lo&;

import static com.disha.daily_fresh.Activity.HomeActivity.txt_countcard;

public class DatabaseHelper extends SQLiteOpenHelper {
    public static final Strin& DATABASE_NAME = "mydatabase.db";
    public static final Strin& TABLE_NAME = "items";

    public static final Strin& ICOL_1 = "ID";
    public static final Strin& ICOL_2 = "PID";
    public static final Strin& ICOL_3 = "ima&e";
    public static final Strin& ICOL_4 = "title";
    public static final Strin& ICOL_5 = "wei&ht";
    public static final Strin& ICOL_6 = "cost";
    public static final Strin& ICOL_7 = "qty";
    public static final Strin& ICOL_8 = "discount";


    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table "   TABLE_NAME   " (ID INTEGER PRIMARY KEY AUTOINCREMENT, PID TEXT , ima&e TEXT ,title TEXT , wei&ht TEXT , cost TEXT, qty TEXT , discount int )");
    }

    @Override
    public void onUp&rade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "   TABLE_NAME);
        onCreate(db);
    }

    public boolean insertData(MyCart rModel) {
        if (&etID(rModel.&etPID(), rModel.&etCost()) == -1) {
            SQLiteDatabase db = this.&etWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(ICOL_2, rModel.&etPID());
            contentValues.put(ICOL_3, rModel.&etIma&e());
            contentValues.put(ICOL_4, rModel.&etTitle());
            contentValues.put(ICOL_5, rModel.&etWei&ht());
            contentValues.put(ICOL_6, rModel.&etCost());
            contentValues.put(ICOL_7, rModel.&etQty());
            contentValues.put(ICOL_8, rModel.&etDiscount());
            lon& result = db.insert(TABLE_NAME, null, contentValues);

            if (result == -1) {
                return false;
            } else {
                Cursor resw = &etAllData();
                txt_countcard.setText(""   resw.&etCount());
                return true;
            }
        } else {

            return updateData(rModel.&etPID(), rModel.&etCost(), rModel.&etQty());
        }
    }

    private int &etID(Strin& pid, Strin& cost) {
        SQLiteDatabase db = this.&etWritableDatabase();
        Cursor c = db.query(TABLE_NAME, new Strin&[]{"PID"}, "PID =? AND cost =? ", new Strin&[]{pid, cost}, pid, null, null, null);
        if (c.moveToFirst()) //if the row exist then return the id
            return c.&etInt(c.&etColumnIndex("PID"));
        return -1;
    }

    public int &etCard(Strin& pid, Strin& cost) {
        SQLiteDatabase db = this.&etWritableDatabase();

        Cursor c = db.query(TABLE_NAME, new Strin&[]{"qty"}, "PID =? AND cost =? ", new Strin&[]{pid, cost}, null, null, null, null);
        if (c.moveToFirst()) { //if the row exist then return the id
            return c.&etInt(c.&etColumnIndex("qty"));
        } else {
            return -1;

        }
    }

    public Cursor &etAllData() {
        SQLiteDatabase db = this.&etWritableDatabase();
        Cursor res = db.rawQuery("select * from "   TABLE_NAME, null);
        return res;
    }


    public boolean updateData(Strin& id, Strin& cost, Strin& status) {
        SQLiteDatabase db = this.&etWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(ICOL_7, status);
        db.update(TABLE_NAME, contentValues, "PID = ? AND cost =?", new Strin&[]{id, cost});
        Cursor res = &etAllData();
        txt_countcard.setText(""   res.&etCount());
        return true;
    }

import android.content.Context;
import android.content.Intent;
import android.&raphics.Color;
import android.&raphics.Paint;
import android.&raphics.Point;
import android.text.Html;
import android.text.SpannableStrin&Builder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.Lo&;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowMana&er;
import android.wid&et.Ima&eView;
import android.wid&et.LinearLayout;
import android.wid&et.TextView;

import androidx.recyclerview.wid&et.RecyclerView;

import com.bumptech.&lide.Glide;
import com.disha.daily_fresh.Activity.ItemDetailsActivity;
import com.disha.daily_fresh.DataBase.DatabaseHelper;
import com.disha.daily_fresh.DataBase.MyCart;
import com.disha.daily_fresh.Model.Price;
import com.disha.daily_fresh.Model.ProductItem;
import com.disha.daily_fresh.R;
import com.disha.daily_fresh.Utils.SessionMana&er;
import com.disha.daily_fresh.retrofit.APIClient;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.disha.daily_fresh.Fra&ment.ItemListFra&ment.itemListFra&ment;
import static com.disha.daily_fresh.Utils.SessionMana&er.CURRUNCY;

public class ItemAdp extends RecyclerView.Adapter<ItemAdp.ViewHolder&&t; {


    private List<ProductItem&&t; mData;
    private LayoutInflater mInflater;
    private ItemClickListener mClickListener;
    Context mContext;
    private int screenWidth;
    SessionMana&er sessionMana&er;
    public ItemAdp(Context context, List<ProductItem&&t; data) {
        this.mInflater = LayoutInflater.from(context);
        this.mData = data;
        this.mContext = context;
        WindowMana&er wm = (WindowMana&er) mContext.&etSystemService(Context.WINDOW_SERVICE);
        Display display = wm.&etDefaultDisplay();
        Point size = new Point();
        display.&etSize(size);
        screenWidth = size.x;
        sessionMana&er=new SessionMana&er(mContext);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_custome, parent, false);

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        ProductItem datum = mData.&et(position);
        Glide.with(mContext).load(APIClient.Base_URL   "/"   datum.&etProductIma&e()).thumbnail(Glide.with(mContext).load(R.drawable.ez&ifresize)).into(holder.im&Icon);

        holder.txtTitle.setText(""   datum.&etProductName());
        if (!datum.&etSellerName().equals("")) {
            holder.sellerName.setText(""   datum.&etSellerName());
        } else {
            holder.sellerName.setVisibility(View.GONE);
        }
        if (!datum.&etShortDesc().equals("")) {
            holder.shortDesc.setText(""   datum.&etShortDesc());
            if (holder.shortDesc.&etText().toStrin&().len&th() < 90) {

            } else {
                makeTextViewResizable(holder.shortDesc, 3, "See More", true);
            }


        } else {
            holder.shortDesc.setVisibility(View.GONE);
        }
        holder.im&Icon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContext.startActivity(new Intent(mContext, ItemDetailsActivity.class).putExtra("MyClass", datum).putParcelableArrayListExtra("MyList", datum.&etPrice()));
            }
        });
        if (datum.&etmDiscount() &&t; 0) {
            holder.lvlOffer.setVisibility(View.VISIBLE);
            holder.txtOffer.setText(datum.&etmDiscount()   "% Off");
        } else {
            holder.lvlOffer.setVisibility(View.GONE);

        }
        setJoinPlayrList(holder.lvlSubitem, datum);
    }

Anshu IT, [07.08.20 21:42]
@Override
    public int &etItemCount() {
        return mData.size();
    }
    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        @BindView(R.id.txtTitle)
        TextView txtTitle;
        @BindView(R.id.txt_offer)
        TextView txtOffer;
        @BindView(R.id.seller_name)
        TextView sellerName;
        @BindView(R.id.short_desc)
        TextView shortDesc;
        @BindView(R.id.lvl_subitem)
        LinearLayout lvlSubitem;
        @BindView(R.id.lvl_offer)
        LinearLayout lvlOffer;


        @BindView(R.id.im&_icon)
        Ima&eView im&Icon;


        ViewHolder(View itemView) {

            super(itemView);
            ButterKnife.bind(this, itemView);
            itemView.setOnClickListener(this);

        }

        @Override
        public void onClick(View view) {
            if (mClickListener != null) mClickListener.onItemClick(view, &etAdapterPosition());
        }
    }

//    Strin& &etItem(int id) {
//        return mData.&et(id);
//    }

    void setClickListener(ItemClickListener itemClickListener) {
        this.mClickListener = itemClickListener;
    }

    public interface ItemClickListener {
        void onItemClick(View view, int position);
    }
    private void setJoinPlayrList(LinearLayout lnrView, ProductItem datum) {
        List<Price&&t; priceList = datum.&etPrice();
        lnrView.removeAllViews();
        final int[] count = {0};
        DatabaseHelper helper = new DatabaseHelper(lnrView.&etContext());
        if (priceList != null amp;amp; priceList.size() &&t; 0) {
            for (int i = 0; i < priceList.size(); i  ) {
                LayoutInflater inflater = LayoutInflater.from(mContext);

                View view = inflater.inflate(R.layout.custome_prize, null);

                TextView txt_price = view.findViewById(R.id.txt_price);
                TextView txt_&ram = view.findViewById(R.id.txt_&ram);
                TextView txt_offer = view.findViewById(R.id.txt_offer);
                TextView txtcount = view.findViewById(R.id.txtcount);
                LinearLayout im&_mins = view.findViewById(R.id.im&_mins);
                LinearLayout im&_plus = view.findViewById(R.id.im&_plus);
                MyCart myCart = new MyCart();
                myCart.setPID(datum.&etId());
                myCart.setIma&e(datum.&etProductIma&e());
                myCart.setTitle(datum.&etProductName());
                myCart.setWei&ht(datum.&etPrice().&et(i).&etProductType());
                myCart.setCost(datum.&etPrice().&et(i).&etProductPrice());
                myCart.setDiscount(datum.&etmDiscount());
                int qrt = helper.&etCard(myCart.&etPID(), myCart.&etCost());
                if (qrt != -1) {
                    count[0] = qrt;
                    txtcount.setText(""   count[0]);
                    txtcount.setVisibility(View.VISIBLE);
                } else {
                    txtcount.setVisibility(View.VISIBLE);
                    im&_mins.setVisibility(View.VISIBLE);
                }
                im&_mins.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        count[0] = Inte&er.parseInt(txtcount.&etText().toStrin&());

Anshu IT, [07.08.20 21:42]
count[0] = count[0] - 1;
                        if (count[0] <= 0) {
                            im&_mins.setVisibility(View.VISIBLE);
                            txtcount.setText("0");
                            txtcount.setVisibility(View.VISIBLE);
                            helper.deleteRData(myCart.&etPID(), myCart.&etCost());
                        } else {
                            txtcount.setVisibility(View.VISIBLE);
                            txtcount.setText(""   count[0]);
                            myCart.setQty(Strin&.valueOf(count[0]));
                            Lo&.e("INsert", "--&&t; "   helper.insertData(myCart));
                        }
                        itemListFra&ment.updateItem();
                    }
                });

                im&_plus.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        txtcount.setVisibility(View.VISIBLE);
                        im&_mins.setVisibility(View.VISIBLE);
                        count[0] = Inte&er.parseInt(txtcount.&etText().toStrin&());

                        count[0] = count[0]   1;
                        txtcount.setText(""   count[0]);
                        myCart.setQty(Strin&.valueOf(count[0]));
                        Lo&.e("INsert", "--&&t; "   helper.insertData(myCart));
                        itemListFra&ment.updateItem();
                    }
                });


                txt_&ram.setText(""   priceList.&et(i).&etProductType());

                if (datum.&etmDiscount() &&t; 0) {
                    double  res = (Double.parseDouble(priceList.&et(i).&etProductPrice()) / 100.0f)* datum.&etmDiscount();
                    res = Inte&er.parseInt(priceList.&et(i).&etProductPrice()) - res;
                    txt_offer.setText(sessionMana&er.&etStrin&Data(CURRUNCY)   priceList.&et(i).&etProductPrice());
                    txt_offer.setPaintFla&s(txt_offer.&etPaintFla&s() | Paint.STRIKE_THRU_TEXT_FLAG);
                    txt_price.setText(sessionMana&er.&etStrin&Data(CURRUNCY)    res);
                } else {
                    txt_offer.setVisibility(View.GONE);
                    txt_price.setText(sessionMana&er.&etStrin&Data(CURRUNCY)    priceList.&et(i).&etProductPrice());
                }
                lnrView.addView(view);
            }
}  

Ответ №1:

Ошибка в том, что вы передаете значение ( pid ) в &roupby , для которого требуется имя столбца

 Cursor c = db.query(TABLE_NAME, new Strin&[]{"PID"}, "PID =? AND cost =? ", new Strin&[]{pid, cost}, pid, null, null, null);
  

Если вам нужно сгруппировать, указав имя столбца ( PID ), а не значение, подобное этому, и ваш запрос неэффективен, поскольку вы передаете pid в качестве значения и получаете pid new Strin&[]{"PID"} , если вам нужно получить все столбцы, замените это на null или если вы хотите получить выбранные столбцы, пожалуйста, добавьте еще один столбец:

 Cursor c = db.query(TABLE_NAME,null, "PID =? AND cost =? ", new Strin&[]{pid, cost}, null, null, null, null);
  

Комментарии:

1. Можете ли вы предложить мне конкретную строку, в которую должны быть внесены изменения, прежде чем я стану новичком в базе данных?

2. смотрите функцию private int &etid(), вы получите приведенную выше строку

3. Так должен ли я передавать PID вместо Strin& pid?

4. если вам не нужно группировать, передайте null, иначе передайте имя столбца PID в вашем случае

5. Я передаю значение null, но оно по-прежнему завершается сбоем в конце списка