繁体   English   中英

检索指纹Blob在运行时使应用程序崩溃,适用于Android的SQLITE

[英]Retrieving a fingerprint Blob is Crashing the app at run time, SQLITE for Android

已记录以下错误

在com.github.omadahealth.lollipin.DatabaseHelper.userFP1(DatabaseHelper.java:400)在com.magtouch.app.gateopen $ 22.onUpCharSuccess(gateopen.java:777)在android_serialport_api.AsyncFingerprint.handleMessage(AsyncFingerprint.java:126)

数据库功能

public byte[] userFP1(int userID){
        SQLiteDatabase db = this.getWritableDatabase();
        Cursor cursor = db.query(TABLE_USERS, new String[]{FINGER_PRINT1}, USER_ID + "=?", new String[]{String.valueOf(userID)}, null, null, null, null);

        if (cursor != null) {
            cursor.moveToFirst();
        }
        return cursor.getBlob (10  );

    }

代码调用数据库

    if(db.userFP1 (i)!=null){
                        System.arraycopy( db.userFP1 ( i ), 0, tmp, 0, 256);
                        if(FPMatch.getInstance().MatchTemplate(model,tmp)>60){
                            tvFpStatus.setText(getString( R.string.txt_fpmatchok));
                            break;
                        }
Section pointed by the error from (AsyncFingerprint.java:126)
if (msg.obj != null) {
                        onUpCharListener.onUpCharSuccess((byte[]) msg.obj);
                    } else {
                        onUpCharListener.onUpCharFail();
                    }

以下代码为我工作

public byte[] userFP1(int userID){
        SQLiteDatabase db = this.getReadableDatabase ();
        Cursor cursor = db.query(TABLE_USERS, new String[]{FINGER_PRINT1}, USER_ID + "=?", new String[]{String.valueOf(userID)}, null, null, null, null);

        if (cursor.moveToFirst()){
            byte[] imgByte = cursor.getBlob(0);
            cursor.close();
            return imgByte;
        }
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
        return null;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM