zxing android creating a list of scanned codes

364 views Asked by At

So I am building an app which keeps track of items on loan to students. What I want to do is be able to scan the barcode on the student card, and scan the barcode on the item they are borrowing. This information should then be added to a "Loan" database table.

This should be able to be done multiple times, as there will be more than one student borrowing items at any one time. So when we are finished, the UI of the android app will have a list of student numbers retrieved from their student cards alongside the item they are borrowing.

I have embedded zxing into my app and I am already successfully scanning barcodes. I have just reached a point where I cannot think how to proceed with this next stage.

I think my main problem is that onActivityResult is retrieving the read data, and then it is being overwritten with every new barcode I scan. Is there any way I can scan multiple barcodes and save the data of each without overwriting?

From my Scan.java:

    public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

    if (scanningResult != null) {
    //we have a result
        String scanContent = scanningResult.getContents();
        String scanFormat = scanningResult.getFormatName();

        formatTxt.setText("FORMAT: " + scanFormat);
        contentTxt.setText("CONTENT: " + scanContent);


    } else {
        Toast toast = Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_SHORT);
        toast.show();
    }
}

The table that loans information will be stored in. From DBHelper.java:

     private static final String SQL_CREATE_TABLE_ONLOAN = "CREATE TABLE " + TABLE_ONLOAN + "("
        + COLUMN_ONLOAN_LOAN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
        + COLUMN_ONLOAN_KIT_NUMBER + " TEXT NOT NULL, "
        + COLUMN_ONLOAN_BORROWER_NUMBER + " TEXT NOT NULL, "
        + COLUMN_ONLOAN_DATE_BORROWED + " DATE NOT NULL "
        + ");";
0

There are 0 answers