Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.database.Cursor;

public class Main {
    public static String logCursor(String prefix, Cursor cr) {
        StringBuilder sb = new StringBuilder().append(prefix + ": ");
        for (int i = 0; i < cr.getColumnCount(); i++) {
            sb.append(cr.getColumnName(i)).append("=");
            switch (cr.getType(i)) {
            case Cursor.FIELD_TYPE_NULL:
                sb.append("NULL");
                break;
            case Cursor.FIELD_TYPE_STRING:
                sb.append("\"").append(cr.getString(i)).append("\"");
                break;
            case Cursor.FIELD_TYPE_INTEGER:
                sb.append(cr.getInt(i));
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                sb.append(cr.getFloat(i));
                break;
            case Cursor.FIELD_TYPE_BLOB:
                sb.append("BIN(").append(cr.getBlob(i).length).append("b)");
                break;
            }
            sb.append(" ");
        }
        return sb.toString();
    }
}