-1

Hi I am trying to insert values in my sqlite database but i get "unrecognized token" for the last value exception for byte array. here is code:

 public void insertImage(String userName, String userMob, String meterReading, String readingAddress, String readingRemark, String readingDate , byte[] imageBytes) {
        try {
            mDb.execSQL("INSERT INTO " + IMAGES_TABLE +"(" + USER_NAME + ", " + USER_MOB + ", " + METER_READING_TEXT + ", " + READING_REMARKS + ", " + READING_DATE + ", " + IMAGE + ")" +
                    " VALUES (" + userName + ", " + userMob + ", " + meterReading + ", " + readingAddress + ", " + readingRemark + ", " + readingDate + ", " + imageBytes + ");");
        }
        catch (Exception ex){
            ex.printStackTrace();
            Log.e("-----","dasdasdas");
        }
        }
Shahid Sarwar
  • 1,209
  • 14
  • 29

1 Answers1

0

seems you have 6 entry in into clause but 7 in values

try {
        mDb.execSQL("INSERT INTO " + IMAGES_TABLE + 
          "(" + USER_NAME + ", " +
           USER_MOB + ", " + 
           METER_READING_TEXT + ", " + 
           READING_REMARKS + ", " + 
           READING_DATE + ", " + 
           IMAGE + ")" +
          " VALUES (" + userName + ", " +
           userMob + ", " + 
           meterReading + ", " + 
           readingAddress + ", " + 
           readingRemark + ", " + 
           readingDate + ", " + 
           imageBytes + ");");
    }

the number of element in both clause must match

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107