java - load image from storage and display it into listview -


i creating application in want load images device gallery , display listview.

i need step step working code example

here code getting list of images gallery -

public static arraylist<string> getimagesfromgallery(activity activity) {      uri uri;      cursor cursor;      int column_index_data, column_index_folder_name;      arraylist<string> listofallimages = new arraylist<string>();      string absolutepathofimage = null;      uri = android.provider.mediastore.images.media.external_content_uri;       string[] projection = { mediacolumns.data,         mediastore.images.media.bucket_display_name };       cursor = activity.getcontentresolver().query(uri, projection, null,         null, null);       column_index_data = cursor.getcolumnindexorthrow(mediacolumns.data);      column_index_folder_name = cursor         .getcolumnindexorthrow(mediastore.images.media.bucket_display_name);      while (cursor.movetonext()) {     absolutepathofimage = cursor.getstring(column_index_data);       listofallimages.add(absolutepathofimage);     }      return listofallimages;  } 

after can create custom adapter class , display images.

also remember 1 more thing add in manifest file of app -

<uses-permission android:name="android.permission.read_external_storage" /> 

hope you.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -