Find the Last photo taken!!?plzzzzz

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Find the Last photo taken!!?plzzzzz

Postby hadiosbourne » Wed Nov 11, 2009 12:25 pm

Hi everyone i'm looking for a method to invoke the location of the last image taken in the gallery,
does any one has any suggestions? thanks!!
Using this method i'm able to get the first image,but i'm looking for the last image,thanks!!



String [] proj={MediaStore.Images.Media.DATA};
//String [] date={MediaStore.Images.Media.DATE_TAKEN};
// Now we create the cursor pointing to the external thumbnail store
cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)

column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToPosition((int)getSelectedItemId());
// And here we get the filename
String filepath = cursor.getString(column_index);
hadiosbourne
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 06, 2009 10:58 am

Top

Re: Find the Last photo taken!!?plzzzzz

Postby jagtap.jj1 » Tue Nov 17, 2009 4:49 am

Fire the query for DESC order of MediaStore.Images.Media.DATE_TAKEN
So that the Cursor will contain first image as the latest image taken.

hadiosbourne wrote:Hi everyone i'm looking for a method to invoke the location of the last image taken in the gallery,
does any one has any suggestions? thanks!!
Using this method i'm able to get the first image,but i'm looking for the last image,thanks!!



String [] proj={MediaStore.Images.Media.DATA};
//String [] date={MediaStore.Images.Media.DATE_TAKEN};
// Now we create the cursor pointing to the external thumbnail store
cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)

column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToPosition((int)getSelectedItemId());
// And here we get the filename
String filepath = cursor.getString(column_index);
java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Postby hadiosbourne » Wed Nov 18, 2009 10:32 pm

Thanks man! you saved mee!!
hadiosbourne
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 06, 2009 10:58 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests