Java tutorial
//package com.java2s; //License from project: Open Source License import android.database.Cursor; import android.database.DatabaseUtils; public class Main { private static String dumpRow(Cursor c) { String result = "VALUES("; for (int pos = 0; pos < c.getColumnCount(); pos++) { switch (c.getType(pos)) { case Cursor.FIELD_TYPE_NULL: result += "null"; break; case Cursor.FIELD_TYPE_INTEGER: result += Integer.toString(c.getInt(pos)); break; case Cursor.FIELD_TYPE_FLOAT: result += Float.toString(c.getFloat(pos)); break; case Cursor.FIELD_TYPE_STRING: result += DatabaseUtils.sqlEscapeString(c.getString(pos)); break; case Cursor.FIELD_TYPE_BLOB: result += "X'"; for (byte b : c.getBlob(pos)) { result += String.format("%02X", b); } result += "'"; break; default: return "Invalid field type " + c.getType(pos) + " at position " + pos; } if (pos < c.getColumnCount() - 1) { result += ", "; } } return result + ")"; } }