lundi 2 mai 2016

Android-android.database.sqlite.SQLiteException: unknown error (code 0): INTEGER data in nativeGetBlob

I am working on database and exporting data from database to xml file but i faced this error in this line byte[] s = cur.getBlob(idx);. before I was using this line. String s=cur.getString(idx);. But it was also throwing error. Then I found solution to change it in blob type. Here is my code. Please give some suggestion or answer.

 private void exportTable(String tableName) throws IOException {
        mExporter.startTable(tableName);

        // get everything from the table
        String sql = "select * from " + tableName;
        Cursor cur = mDb.rawQuery(sql, new String[0]);
        int numcols = cur.getColumnCount();

        cur.moveToFirst();

        // move through the table, creating rows
        // and adding each column with name and value
        // to the row
        while (cur.getPosition() < cur.getCount()) {
            mExporter.startRow();
            String name;
            String val;
            for (int idx = 0; idx < numcols; idx++) {
                name = cur.getColumnName(idx);
                byte[] s = cur.getBlob(idx);
                val=new String(s,"UTF-8");
                mExporter.addColumn(name, val);
            }

            mExporter.endRow();
            cur.moveToNext();
        }

        cur.close();

        mExporter.endTable();
    }

here is the error log

05-02 16:15:53.417  31609-31609/com.android.lunchernewone E/Launcher.Workspace﹕ Skipping child, screenId 3 not found
05-02 16:15:53.427  31609-31609/com.android.lunchernewone E/Launcher.Workspace﹕ Skipping child, screenId 3 not found
05-02 16:15:57.897  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{com.android.calendar/com.android.calendar.widget.CalendarTypeAppWidgetProvider} can not fit on this device (1260, 1260)
05-02 16:15:57.897  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{com.lge.appwidget.clock/com.lge.variousstyle.quickcover.widget.QuickCoverProvider_01} has invalid dimensions (-2, -2)
05-02 16:15:57.907  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{com.lge.appwidget.clock/com.lge.variousstyle.digitalclock.widget.ClockDigitalWidgetProvider_dual} has invalid dimensions (-2, -2)
05-02 16:15:57.977  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{http://ift.tt/24idcns} can not fit on this device (1170, 330)
05-02 16:15:57.987  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{com.lge.sizechangable.weather/com.lge.sizechangable.weather.layout.Weather4x2} can not fit on this device (1200, 480)
05-02 16:15:57.997  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{com.lge.sizechangable.weather/com.lge.sizechangable.weather.layout.Weather4x1} can not fit on this device (1200, 240)
05-02 16:15:57.997  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{com.lge.sizechangable.weather/com.lge.sizechangable.weather.layout.WeatherFph} can not fit on this device (30000, 30000)
05-02 16:15:58.007  31609-31609/com.android.lunchernewone E/AppsCustomizePagedView﹕ Widget ComponentInfo{com.lge.sizechangable.worldclock/com.lge.sizechangable.worldclock.WorldClock4X2} can not fit on this device (1104, 438)
05-02 16:16:47.257  31609-31609/com.android.lunchernewone E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.android.lunchernewone, PID: 31609
    android.database.sqlite.SQLiteException: unknown error (code 0): INTEGER data in nativeGetBlob
            at android.database.CursorWindow.nativeGetBlob(Native Method)
            at android.database.CursorWindow.getBlob(CursorWindow.java:399)
            at android.database.AbstractWindowedCursor.getBlob(AbstractWindowedCursor.java:45)
            at com.android.lunchernewone.DatabaseDump.exportTable(DatabaseDump.java:93)
            at com.android.lunchernewone.DatabaseDump.exportData(DatabaseDump.java:62)
            at com.android.lunchernewone.Launcher.getDB(Launcher.java:3021)
            at com.android.lunchernewone.Launcher$20.onClick(Launcher.java:2921)
            at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:941)
            at android.widget.AdapterView.performItemClick(AdapterView.java:299)
            at android.widget.AbsListView.performItemClick(AbsListView.java:1158)
            at android.widget.AbsListView$PerformClick.run(AbsListView.java:2957)
            at android.widget.AbsListView$3.run(AbsListView.java:3849)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5105)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)

Aucun commentaire:

Enregistrer un commentaire