Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteException; import android.net.Uri; import android.provider.MediaStore; public class Main { public static int getOrientation(Context context, Uri uri) { Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null); if (cursor == null) { return 0; } if (cursor.moveToNext()) { int ori = cursor.getInt(0); return ori; } else { return -1; } } catch (SQLiteException e) { return 0; } finally { if (cursor != null) { cursor.close(); } } } }