Find the Last photo taken!!?plzzzzz

Put your problem here if it does not fit any of the other categories.

Find the Last photo taken!!?plzzzzz

Postby hadiosbourne » Wed Nov 11, 2009 12:21 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

Postby I_Artist » Wed Nov 11, 2009 3:50 pm

Maybe you would get a quicker answer if you would post this in the Database section...

Cheers!
The I_Artist

follow me on Twitter: @I_Artist
follow Android Development on Twitter: #androiddev

Show the world that you are an #androiddev, wear the badge http://www.twibbon.com/join/androiddev
User avatar
I_Artist
Developer
Developer
 
Posts: 33
Joined: Fri Oct 16, 2009 3:49 am
Location: St-Eustache, Quebec

Postby hadiosbourne » Mon Nov 16, 2009 5:15 pm

Belive me,i've tried anywhere you think! i didn't get a single answer,and i'm really in need,and don't know what to do!
hadiosbourne
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 06, 2009 10:58 am

Postby qlimax » Tue Nov 17, 2009 1:43 am

sorry what is that?

cursor.moveToPosition((int)getSelectedItemId());

have you tried

cursor.moveToLast();

?(sorry...just speculating...)
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby hadiosbourne » Mon Nov 30, 2009 7:58 am

Yes thats right,igot that piece of code from somewhere else and didn't change that part,anyway this also works fine:

String [] proj={MediaStore.Images.Media.DATA};

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)
MediaStore.Images.Media.DATE_TAKEN + " DESC"); // Order-by clause (ascending by name)

column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToPosition((int)getSelectedItemId());
hadiosbourne
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 06, 2009 10:58 am

Postby hadiosbourne » Mon Nov 30, 2009 8:00 am

or this as qlimax mentioned:

String [] proj={MediaStore.Images.Media.DATA};

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.moveToLast();
hadiosbourne
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 06, 2009 10:58 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests