Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save Image in Gallery

This is my code and I want the save image button to simply save the image to the gallery.

package com.nk_apps.hip.hop.lyric.wallpapers;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class Wallpapers extends Activity implements OnClickListener {
}
    ImageView display;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.wallpapers);

        display = (ImageView) findViewById(R.id.IVDisplay);
        ImageView image1 = (ImageView) findViewById(R.id.IVimage1);
        ImageView image2 = (ImageView) findViewById(R.id.IVimage2);
        ImageView image3 = (ImageView) findViewById(R.id.IVimage3);
        ImageView image4 = (ImageView) findViewById(R.id.IVimage4);
        ImageView image5 = (ImageView) findViewById(R.id.IVimage5);
        ImageView image6 = (ImageView) findViewById(R.id.IVimage6);
        ImageView image7 = (ImageView) findViewById(R.id.IVimage7);
        ImageView image8 = (ImageView) findViewById(R.id.IVimage8);
        ImageView image9 = (ImageView) findViewById(R.id.IVimage9);
        Button saveImage = (Button) findViewById(R.id.bSaveImage);

        image1.setOnClickListener(this);
        image2.setOnClickListener(this);
        image3.setOnClickListener(this);
        image4.setOnClickListener(this);
        image5.setOnClickListener(this);
        image6.setOnClickListener(this);
        image7.setOnClickListener(this);
        image8.setOnClickListener(this);
        image9.setOnClickListener(this);
        saveImage.setOnClickListener(this);
    }

    public void onClick(View v) {
        // TODO Auto-generated method stub

        switch (v.getId()) {

        case R.id.IVimage1:
            display.setImageResource(R.drawable.aotl);
            break;
        case R.id.IVimage2:
            display.setImageResource(R.drawable.ball_so_hard);
            break;
        case R.id.IVimage3:
            display.setImageResource(R.drawable.eye);
            break;
        case R.id.IVimage4:
            display.setImageResource(R.drawable.faded);
            break;
        case R.id.IVimage5:
            display.setImageResource(R.drawable.hiii_power);
            break;
        case R.id.IVimage6:
            display.setImageResource(R.drawable.i_invented_swag);
            break;
        case R.id.IVimage7:
            display.setImageResource(R.drawable.lifes_a_bitch);
            break;
        case R.id.IVimage8:
            display.setImageResource(R.drawable.mack_truck);
            break;
        case R.id.IVimage9:
            display.setImageResource(R.drawable.opposite);
            break;
        case R.id.bSaveImage:

            break;
        }

    } }

I want to know what to put under the last case. And if I shouldn't put it there could I be told how exactly?

Thanks for any help, really struggling with taking everything in.

like image 641
user1619978 Avatar asked Aug 26 '12 22:08

user1619978


People also ask

How do I save a picture to my gallery?

Touch and hold the image. Select a save option (e.g., Save attachment, Save to SD card, etc.). Unless otherwise specified, the image is saved to the default picture/video location (e.g., Gallery, Photos, etc.).

Why images are not saving in gallery?

This can cause issues like the pictures taken with the camera don't save in Gallery. Though, you can easily fix this by visiting your Android phone's Settings > Apps > Camera and tapping on the “Storage” or “Manage Storage” option. From here, you can just tap on the “Clear Cache” button to get rid of its cache content.

How do I save a picture on my Android?

Open your web browser and navigate to the Convert JPG to PDF tool. Tap Select a File and choose your picture. The tool automatically converts your picture to a PDF.

Where are my gallery photos stored?

When you turn on back up and sync, your photos are stored in photos.google.com. Learn other ways to find your photos. Important: If your Google Photos account is inactive for 2 years or you're over your storage limit, it may impact your content. Learn how your Google storage works.


1 Answers

Saving any image in the Gallery can be done by :

MediaStore.Images.Media.insertImage(getContentResolver(), yourBitmap, yourTitle , yourDescription);
like image 167
Swayam Avatar answered Oct 19 '22 19:10

Swayam