Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import android.content.ContentResolver;

import android.database.Cursor;
import android.net.Uri;

public class Main {
    public static ArrayList<String> getColumns(ContentResolver resolver, String uri, String[] projectionArray) {
        //String returnValue = "";
        ArrayList<String> columns = new ArrayList<String>();

        try {
            //Issue query
            Cursor c = resolver.query(Uri.parse(uri), projectionArray, null, null, null);

            //Get all column names and display
            if (c != null) {
                String[] colNames = c.getColumnNames();

                //Close the cursor
                c.close();

                //String columnNamesOutput = "";
                for (int k = 0; k < colNames.length; k++)
                    columns.add(colNames[k]);
            }
        } catch (Throwable t) {
        }

        return columns;

    }
}