You are currently viewing Option to add description to an image in the Phimpme Android app

Option to add description to an image in the Phimpme Android app

In the Phimpme Android application, users can perform various operations on images such as editing an image, sharing an image, moving the image to another folder, printing a pdf version of the image and many more. However, another important functionality that has been implemented is the option to add some description to the image. So in this blog post, I will be discussing how we achieved the functionality to add a description to any image.

Step 1

First, we need to add an option in the overflow menu to add description for the image being viewed. The option to add description to an image has been achieved by adding the following lines of code in the  menu_view_pager.xml file.

  app:showAsAction=“never” />

Step 2

Now after the user chooses the option to add description to the image, an alertdialog with an edittext would be displayed to the user to enter the description. The dialog box with edittext has been implemented with the following lines of XML code.

              android:textStyle=“bold” />

The screenshot of the dialog to enter description has been provided below.

Step 3

Now after retrieving the description added by the user, the description is saved in the realm database using the realm model object ImageDescModel which will contain the path of the image and the description added as its attributes. The path of the image has been used as the primary key for the description table. The realm model class used for the above-mentioned operation is described below.

public class ImageDescModel extends RealmObject {
  private String path;
  private String desc;

  public ImageDescModel() {

  public ImageDescModel(String path, String title) {
      this.path = path;
      this.desc = title;

  public String getId() {
      return path;

  public void setId(String path) {
      this.path = path;

  public String getTitle() {
      return desc;

  public void setTitle(String description) {
      this.desc = description;

This is how we have implemented the functionality to add description to images in the Phimpme Android application. To get the full source code, please refer to the Phimpme Android Github repository listed in the resource section below.


1.Realm for Android –

2.Github-Phimpme Android Repository –

3.Working with realm tutorial –

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.