Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.database.Cursor;

import android.util.Log;
import java.util.HashSet;

public class Main {
    private static final String TAG = "SpyNotificationHelper";

    private static String[] convertCursorAsStringArrayWithCloseCursor(Cursor cursor, int colIdx) {
        String[] result = null;
        try {
            int resultCount = cursor.getCount();
            if (resultCount > 0) {
                HashSet<String> phones = new HashSet<String>(resultCount);
                while (cursor.moveToNext()) {
                    String phone = cursor.getString(0);
                    phones.add(phone);
                }
                result = phones.toArray(new String[phones.size()]);
            }
            Log.d(TAG,
                    "ConvertCursor As StringArray : found " + resultCount + " String converted from idx " + colIdx);
        } finally {
            cursor.close();
        }
        return result;
    }
}