jeudi 5 novembre 2015

I am having error to display the image file save in memory in android,

Vote count: -2

Here is the code :- public void Displayimg(View v) {

    File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MyCameraApp");


    ipath[0] = String.valueOf(((TextView) v).getText());


    String  sifile = ipath[0].substring(45,52);  // extracting the filename from the view eg: abc.jpg


    File imgfile = new File(path,sifile);  // it fails on this line with unfortunately, main application has stopped. 

// if the sifile conatians a name of the file that exist, it give error and comes out // if I give file name in sifile that does not exisit, if give file does on exisit and comes our with error. // Basically I am having problem to open an image file that exisit and dispaly.

    // File("/storage/sdcard0/Pictures/MyCameraApp/Zimg20151105_1535133.Jpg");



    Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());

    ImageView myImage = (ImageView) findViewById(R.id.mc_imgview);

    if(imgfile.exists()){

        Toast.makeText(getApplicationContext(),file.getAbsolutePath() + "File Exisit", Toast.LENGTH_SHORT).show();
        myImage.setImageBitmap(myBitmap);
    }
    else
    {
        Toast.makeText(getApplicationContext(),file.getAbsolutePath() + " File Does not Exisit", Toast.LENGTH_SHORT).show();
    }


}

asked 9 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



I am having error to display the image file save in memory in android,

Aucun commentaire:

Enregistrer un commentaire