how to get URI of stored images from db and display in image view

user3598648

I am trying to fetch image URL saved in my local sql dB and display it in the image view but some how there is error on my image being null.. i am already reading name of the image and it works perfect but the image uri cant not be displayed, As the URI is being fetch its in String format so need to b decoded first to be displayed.. is there a way to decode it when my cursor fetch URI and decode it send it in list-View for display.

please see the code below: ----------->>>>>>>>>>the class where the fetched data is being displayed

public class NewsFeed_Viewoverlay extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newsfeed_viewoverlay);
        DatabaseHelper helper;
        ImageView list_image;
        VideoView list_video;
        helper= new DatabaseHelper(this.getApplicationContext());
        list_image= (ImageView) findViewById(R.id.list_image);
        list_video = (VideoView)findViewById(R.id.list_video);

//-------------------------------------------------------------------->>>>>>>>XXXXXXXXXXX<<<<<<<<<<-----------------------
        Cursor cursor = helper.getCursor();
        startManagingCursor(cursor);
        //setup for MApping in view fields
        String [] fromFieldNames=new String[]{helper.KEY_NAME,helper.KEY_IMAGE};

       //list_image.setImageBitmap(BitmapFactory.decodeFile(helper.KEY_IMAGE));
       // list_video.setVideoURI(Uri.parse(helper.KEY_FILE));

        int[] toViewID= new int[]{R.id.title, R.id.list_image};
        SimpleCursorAdapter myadaptor= new SimpleCursorAdapter(this, R.layout.list_row, cursor,fromFieldNames,toViewID );
        ListView mylist= (ListView)findViewById(R.id.list);
        mylist.setAdapter(myadaptor);


        Log.i("READ-->Path in DB->", "" + helper.KEY_NAME + helper.KEY_IMAGE);

    }

---------------------->>>>>>>THE Database class for cursor----------------

public void Insert(String imgpath, String vidPath, String name ) throws SQLException {

    db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_IMAGE, imgpath);
    values.put(KEY_FILE, vidPath);
    values.put(KEY_NAME,name);

    db.insert(TABLE_Images, null, values);
    db.close();
    Log.i("INSERTED-->Path in DB->", "" + imgpath);
    Log.i("INSERTED-->Path in DB->", "" + vidPath);
    Log.i("INSERTED-->Path in DB->", "" + name);

}
    public static final String[] KEY= new String[] {KEY_ID,KEY_NAME,KEY_IMAGE,KEY_FILE};
public Cursor getCursor()
{
    String where=null; ContentResolver resolver;
    db= this.getReadableDatabase();
    //db.rawQuery("select image , name from images",null);
    //Cursor cursor = db.rawQuery("select _id, name from images",null);
    Cursor cursor= db.query(true,TABLE_Images,KEY,where,null,null,null,null,null,null);
    if (cursor!=null)
    {
        cursor.moveToFirst();

    }
    return cursor;

}

please refer any links or at-least tell me if there is alternative.

Nigam Patro

After retrieving the URI from database, you need to parse it into URI format.

Uri mUri = Uri.parse("Data you got from db");

After that you can show it in ImageView.

imageView.setImageURI(mUri);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get a Uri of the image stored in the resources

From Dev

How To Display Random images on image view

From Dev

How to display image having fixed Uri in Image View in android

From Dev

How to display image having fixed Uri in Image View in android

From Dev

get URI of image stored in isolatedstorage

From Dev

display images from db

From Dev

How to get Image URI from Gallery?

From Dev

display binary image from db to angular partial view

From Dev

How to view stored images in an array?

From Dev

how to get image url from json string in android to display in image view

From Dev

Javascript display image from uri

From Dev

how to display image from path stored in database? in laravel

From Dev

Cannot get image to display in picturebox when trying to load if from the DB

From Dev

how to get image from drawable according to their names in the sqlite database and then display it in list view

From Dev

How to load multiple images from JSON and display in gallery view in android?

From Dev

How to display a paragraph with images and rich text in android text view. Content can be stored in xml

From Dev

How can i display the file name in the Edit View? File name is stored in the images Folder and also in database

From Dev

How to display a paragraph with images and rich text in android text view. Content can be stored in xml

From Dev

How to get date from time() value stored in DB

From Dev

how to fetch image and display in image view from facebook

From Dev

Get content URI of images stored on sdcard using File Provider

From Dev

how to view images stored in application directory in gallery

From Dev

How to display and explode multiple image from db php?

From Dev

How to get image height and width from uri on React Native?

From Dev

How to Display Blade Content stored in a Db row

From Dev

How to Display Blade Content stored in a Db row

From Dev

Regex to get Images from a Markdown Blurb where Image URI Contains a Closing Bracket

From Dev

How to Retrieve a VarBinary Image from DB to an MVC View

From Dev

Image uri doesn't display images on ImageView on some android device

Related Related

  1. 1

    How to get a Uri of the image stored in the resources

  2. 2

    How To Display Random images on image view

  3. 3

    How to display image having fixed Uri in Image View in android

  4. 4

    How to display image having fixed Uri in Image View in android

  5. 5

    get URI of image stored in isolatedstorage

  6. 6

    display images from db

  7. 7

    How to get Image URI from Gallery?

  8. 8

    display binary image from db to angular partial view

  9. 9

    How to view stored images in an array?

  10. 10

    how to get image url from json string in android to display in image view

  11. 11

    Javascript display image from uri

  12. 12

    how to display image from path stored in database? in laravel

  13. 13

    Cannot get image to display in picturebox when trying to load if from the DB

  14. 14

    how to get image from drawable according to their names in the sqlite database and then display it in list view

  15. 15

    How to load multiple images from JSON and display in gallery view in android?

  16. 16

    How to display a paragraph with images and rich text in android text view. Content can be stored in xml

  17. 17

    How can i display the file name in the Edit View? File name is stored in the images Folder and also in database

  18. 18

    How to display a paragraph with images and rich text in android text view. Content can be stored in xml

  19. 19

    How to get date from time() value stored in DB

  20. 20

    how to fetch image and display in image view from facebook

  21. 21

    Get content URI of images stored on sdcard using File Provider

  22. 22

    how to view images stored in application directory in gallery

  23. 23

    How to display and explode multiple image from db php?

  24. 24

    How to get image height and width from uri on React Native?

  25. 25

    How to Display Blade Content stored in a Db row

  26. 26

    How to Display Blade Content stored in a Db row

  27. 27

    Regex to get Images from a Markdown Blurb where Image URI Contains a Closing Bracket

  28. 28

    How to Retrieve a VarBinary Image from DB to an MVC View

  29. 29

    Image uri doesn't display images on ImageView on some android device

HotTag

Archive