format database Cursor As String Array - Android Database

Android examples for Database:Cursor

Description

format database Cursor As String Array

Demo Code


//package com.book2s;
import java.util.Vector;

import android.database.Cursor;

public class Main {
    public static String[] formatCursorAsStringArray(Cursor cursor) {
        if (cursor.getColumnCount() != 1) {
            return new String[0];
        }/*from w  ww.  ja  v a  2 s . co  m*/
        Vector<String> v = new Vector<String>();
        cursor.moveToFirst();
        do {
            v.add(cursor.getString(0));
        } while (cursor.moveToNext());
        return (String[]) v.toArray();
    }
}

Related Tutorials