android - 对象已收集无法评估 ContentValues.values.tostring()

标签 android android-sqlite content-values

谁能告诉我这是怎么回事。当我在数据库中添加数据时出现此错误。它仅针对特定行发生。我尝试通过互联网寻找答案或理由。但徒劳无功。截图 Screenshot while debugging

public void FunSetVisitorDetails(String strResult) {
    Log.d(TAG, "Get Visitor Details started.");
    if (!strResult.equalsIgnoreCase("NA") && !strResult.equalsIgnoreCase("NI")) {
        SQLiteDatabase database = getWritableDatabase();
        database.delete("TBL_VISITOR_MASTER", null, null);
            String[] strResultData = strResult.split("#");
            for (int index = 0; index < strResultData.length; index++) {
                String[] strRowData = strResultData[index].split(",");
                ContentValues values = new ContentValues();
                values.put("VISITORID", strRowData[0]);
                values.put("MEMBERID", strRowData[1]);
                values.put("TEAMID", strRowData[2]);
                values.put("CATEGORY", strRowData[3]);
                values.put("NAME", strRowData[4]);
                values.put("COMPNAME", strRowData[5]);
                values.put("SPECIALIZED1", strRowData[6]);
                values.put("SPECIALIZED2", strRowData[7]);
                values.put("SPECIALIZED3", strRowData[8]);
                values.put("SPECIALIZED4", strRowData[9]);
                values.put("SPECIALIZED5", strRowData[10]);
                values.put("CLIENT1", strRowData[11]);
                values.put("CLIENT2", strRowData[12]);
                values.put("CLIENT3", strRowData[13]);
                values.put("CLIENT4", strRowData[14]);
                values.put("CLIENT5", strRowData[15]);
                values.put("ASK", strRowData[16]);
                values.put("GIVE", strRowData[17]);
                values.put("TAGLINE", strRowData[18]);
                values.put("EMAIL", strRowData[19]);
                values.put("MOBILE", strRowData[20]);
                values.put("WEBSITE", strRowData[21]);
                values.put("LOCATION", strRowData[22]);
                try{ 
                    values.put("COMP_LOGO", strRowData[23]);// it is happening when adding the logo and image below. there is no exception thrown as well.
                    values.put("PERSON_IMAGE", strRowData[24]);
                } catch (Exception e){
                    e.printStackTrace();
                }

                database.insert("TBL_VISITOR_MASTER", null, values);
            }

最佳答案

我猜是保存图片的错误。您需要保存特定行的位图图像。因此,将列创建为 BLOB 并在其上保存 bytes 的图像。

您会发现很多教程,例如 THIS .

关于android - 对象已收集无法评估 ContentValues.values.tostring(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35519850/

相关文章:

Android - 任何 Activity 的 Root View 层次结构中存在的所有 View 的相对路径生成器

java - 使用gson将json数组转换为android中的json对象?

android - 如何在android中单击listview项目从数据库中获取id

android - 如何以编程方式删除 Android Sqlite 数据库

android - 如何在 Android 应用程序中插入日期时间设置为 'now' 的 SQLite 记录?

android - 如何验证 Web 服务调用的来源

java - 查询仅返回表中的数字或数字+字母组合。如何修改它以显示带字母的记录?

android - 在 android kotlin 中以编程方式创建联系人并将其共享为 v-card/vcf 文件

android - 错误 : undefined reference to 'av_free_packet(AVPacket*)' when use NDK to compile ffmpeg