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.content.Context;

import android.database.Cursor;

import android.provider.MediaStore.Images;

public class Main {
    public static int getLastImageId(Context context) {
        final String[] imageColumns = { Images.Media._ID };
        final String imageOrderBy = Images.Media._ID + " DESC";
        Cursor cursor = context.getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI, imageColumns, null,
                null, imageOrderBy);
        if (cursor == null)
            return 0;
        int id = 0;
        if (cursor.moveToFirst()) {
            id = cursor.getInt(cursor.getColumnIndex(Images.Media._ID));
        }
        cursor.close();
        return id;
    }
}