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.content.Context;
import android.database.Cursor;
import android.provider.MediaStore;

public class Main {
    /**
     * get the sound list of the system
     */
    public static ArrayList<String> getSystemRingList(Context con) {
        ArrayList<String> getArray = new ArrayList<String>();
        ContentResolver cr = con.getContentResolver();
        String[] cols = new String[] { MediaStore.Audio.Media.IS_RINGTONE, MediaStore.Audio.Media._ID,
                MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.DISPLAY_NAME };
        Cursor cursor = cr.query(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, cols, null, null, null);
        if (cursor.moveToFirst()) {
            do {
                if (cursor.getString(0).equals("1")) {
                    getArray.add(cursor.getString(2));
                }

            } while (cursor.moveToNext());
        }
        return getArray;
    }
}