I am trying to build an app that captures an image ans saves the image to a custom folder with a custom name but i am unable to perform it.
Here is the code that I have written please go through the code and correct me where i am wrong.
public class MainActivity extends Activity {
private static final int SELECT_PICTURE = 1;
private String selectedImagePath;
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
private Builder alertDialogBuilder;
final Context context = this;
String name_str;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView)this.findViewById(R.id.imageView1);
Button photoButton = (Button) this.findViewById(R.id.button1);
Button searchButton = (Button) this.findViewById(R.id.button2);
photoButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
searchButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
}
});
}
public void onActivityResult1(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
System.out.println("Image Path : " + selectedImagePath);
imageView.setImageURI(selectedImageUri);
}
}
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
final Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
//Creating Alert Dialog Box
AlertDialog.Builder askname = new AlertDialog.Builder(MainActivity.this);
final EditText inputname = new EditText(this);
askname.setMessage("Enter Name");
askname.setView(inputname);
askname.setPositiveButton("OK",new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
name_str = inputname.getEditableText().toString();
Toast.makeText(context,name_str,Toast.LENGTH_LONG).show();
dialog.dismiss();
/*if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
//photo = BitmapFactory.decodeByteArray(data,0,data.length);
imageView.setImageBitmap(photo);*/
String file ="/DCIM/VisitingCards/";
File folder = new File(Environment.getExternalStorageDirectory() + file);
System.out.println("File name is :"+folder);
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
//ON success
System.out.println("Directory Present");
System.out.println("In Success Case");
try {
FileOutputStream out = new FileOutputStream(folder);
photo.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
} else {
//ON failure
System.out.println("Directory not Present");
System.out.println("In Failure Case");
}
System.out.println("Before the Dialog builder");
}
});
askname.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
dialog.dismiss();
}
}); //End of alert.setNegativeButt
askname.show();
}
}
}
you should ask image name before intent and then used putExtra.
hope it may help you
Related
I am creating an android activity for browsing the images from gallery. But it's taking only images from other folders but not images from the Camera folder.
This code in your button on click
Yourbotton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alertdialog1 =new AlertDialog.Builder(EditProfileActivity.this);
alertdialog1.setMessage("Please select a Profile image");
alertdialog1.setNegativeButton("CAMERA", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent,CAMERA_REQUEST);
}
});
alertdialog1.setNeutralButton("GALLERY",new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
});
alertdialog1.setPositiveButton("CLOSE",new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
alertdialog1.show();
}
});
This functions in outside of onCreate()
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
edpprofilepic.setScaleType(ScaleType.FIT_XY);
edpprofilepic.setImageBitmap(photo);
imagepath = ImageWrite(photo);
}
else if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK
&& null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn,
null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
edpprofilepic.setScaleType(ScaleType.FIT_XY);
edpprofilepic.setImageBitmap(BitmapFactory.decodeFile(picturePath));
imagepath = ImageWrite(BitmapFactory.decodeFile(picturePath));
}
}
public String ImageWrite(Bitmap bitmap1)
{
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
OutputStream outStream = null;
File file = new File(extStorageDirectory, "slectimage.PNG");
try
{
outStream = new FileOutputStream(file);
bitmap1.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
String imageInSD = "/sdcard/slectimage.PNG";
return imageInSD;
}
I think this is helpful to you
this is my program, I think it is no problem about the alertdialogue.
But after I select the photo in my gallery, the picture isn't changed.
It is still the original photo that I set in the ImageView.
Could someboby help me know where the problem is?
public class MainActivity extends Activity{
ImageView img_logo;<br>
protected static final int CAMERA_REQUEST = 0;
protected static final int GALLERY_PICTURE = 1;
private Intent pictureActionIntent = null;
Bitmap bitmap;
Uri selectedImageUri;
String selectedPath;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img_logo= (ImageView) findViewById(R.id.homepic);
img_logo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startDialog();
}
});
}
private void startDialog() {
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
myAlertDialog.setTitle("Upload Pictures Option");
myAlertDialog.setMessage("How do you want to set your picture?");
myAlertDialog.setPositiveButton("Gallery",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
pictureActionIntent = new Intent(
Intent.ACTION_GET_CONTENT, null);
pictureActionIntent.setType("image/*");
pictureActionIntent.putExtra("return-data", true);
startActivityForResult(pictureActionIntent,
GALLERY_PICTURE);
}
});
myAlertDialog.setNegativeButton("Camera",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
pictureActionIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(pictureActionIntent,
CAMERA_REQUEST);
}
});
myAlertDialog.show();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if(data.getData() != null){
selectedImageUri = data.getData();
}else{
Log.d("selectedPath1 : ","Came here its null !");
Toast.makeText(getApplicationContext(), "failed to get Image!", 500).show();
}
if (requestCode == 100 && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
selectedPath = getPath(selectedImageUri);
img_logo.setImageURI(selectedImageUri);
Log.d("selectedPath1 : " ,selectedPath);
}
if (requestCode == 10)
{
selectedPath = getPath(selectedImageUri);
img_logo.setImageURI(selectedImageUri);
Log.d("selectedPath1 : " ,selectedPath);
}
}
Toast toast = Toast.makeText(MainActivity.this, "hiiiii", Toast.LENGTH_LONG);
toast.show();
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}
Try this way,hope this will help you to solve your problem.
public class MainActivity extends Activity {
ImageView img_logo;
protected static final int CAMERA_REQUEST = 0;
protected static final int GALLERY_PICTURE = 1;
private String imgPath;
private String selectedPath;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img_logo = (ImageView) findViewById(R.id.homepic);
img_logo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startDialog();
}
});
}
private void startDialog() {
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
myAlertDialog.setTitle("Upload Pictures Option");
myAlertDialog.setMessage("How do you want to set your picture?");
myAlertDialog.setPositiveButton("Gallery",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, ""), GALLERY_PICTURE);
}
}
);
myAlertDialog.setNegativeButton("Camera",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, setImageUri());
startActivityForResult(intent, CAMERA_REQUEST);
}
}
);
myAlertDialog.show();
}
public Uri setImageUri() {
// Store image in dcim
File file = new File(Environment.getExternalStorageDirectory() + "/DCIM/", "image" + new Date().getTime() + ".jpg");
Uri imgUri = Uri.fromFile(file);
this.imgPath = file.getAbsolutePath();
return imgUri;
}
public String getImagePath() {
return imgPath;
}
public String getAbsolutePath(Uri uri) {
if (Build.VERSION.SDK_INT >= 19) {
String id = uri.getLastPathSegment().split(":")[1];
final String[] imageColumns = {MediaStore.Images.Media.DATA};
final String imageOrderBy = null;
Uri tempUri = getUri();
Cursor imageCursor = managedQuery(tempUri, imageColumns,
MediaStore.Images.Media._ID + "=" + id, null, imageOrderBy);
if (imageCursor.moveToFirst()) {
return imageCursor.getString(imageCursor.getColumnIndex(MediaStore.Images.Media.DATA));
} else {
return null;
}
} else {
String[] projection = {MediaStore.MediaColumns.DATA};
#SuppressWarnings("deprecation")
Cursor cursor = managedQuery(uri, projection, null, null, null);
if (cursor != null) {
int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} else
return null;
}
}
private Uri getUri() {
String state = Environment.getExternalStorageState();
if (!state.equalsIgnoreCase(Environment.MEDIA_MOUNTED))
return MediaStore.Images.Media.INTERNAL_CONTENT_URI;
return MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == CAMERA_REQUEST) {
img_logo.setImageBitmap(BitmapFactory.decodeFile(getImagePath()));
selectedPath = getImagePath();
} else if (requestCode == GALLERY_PICTURE) {
img_logo.setImageBitmap(BitmapFactory.decodeFile(getAbsolutePath(data.getData())));
selectedPath = getAbsolutePath(data.getData());
}
Toast toast = Toast.makeText(MainActivity.this, "hiiiii", Toast.LENGTH_LONG);
toast.show();
}
}
}
Add this <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> in AndroidManifest.xml
I'm making a function which is when I select "Choose from gallery" in an alert dialog box, the selected image inside gallery will appear in the imagebutton. I don't know what's wrong with my code.
I used these website as an example to do it http://geekonjava.blogspot.sg/2014/03/upload-image-on-server-in-android-using.html and http://www.c-sharpcorner.com/UploadFile/e14021/capture-image-from-camera-and-selecting-image-from-gallery-o/ . There isn't any code errors or logcat errors. Can someone help me with this?
Here is my code:
public static class CardFrontFragment extends Fragment implements OnClickListener{
private int serverResponseCode = 0;
private ProgressDialog dialog = null;
private String uploadServerUri = null;
private String imagepath = null;
private ImageButton upload;
public CardFrontFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RelativeLayout layout = (RelativeLayout) inflater.inflate(
R.layout.card_front, container, false);
upload = (ImageButton) layout.findViewById(R.id.fileUpload);
upload.setOnClickListener(this);
uploadServerUri = Constants.serverUrl + "api/FileUpload";
return layout;
}
#Override
public void onClick(View arg0) {
if(arg0 == upload)
{
selectImage();
}
}
private void selectImage() {
final CharSequence[] options = { "Take Photo", "Choose from Gallery","Cancel" };
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Add Photo!");
builder.setItems(options, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int item) {
if (options[item].equals("Take Photo"))
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = new File(android.os.Environment.getExternalStorageDirectory(), "temp.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(intent, 1);
}
else if (options[item].equals("Choose from Gallery"))
{
Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);
}
else if (options[item].equals("Cancel")) {
dialog.dismiss();
}
}
});
builder.show();
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 2 && resultCode == RESULT_OK) {
//Bitmap photo = (Bitmap) data.getData().getPath();
Uri selectedImageUri = data.getData();
imagepath = getPath(selectedImageUri);
Bitmap bitmap=BitmapFactory.decodeFile(imagepath);
upload.setImageBitmap(bitmap);
}
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = getActivity().managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}
And these are the permissions that i have declared in androidmanifest.xml :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Try invalidating your imagebutton. That way you tell the UI that it should be redrawn, because a value changed.
Try changing your onActivityResult to
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1 && resultCode == RESULT_OK) {
Uri selectedImageUri = data.getData();
upload.setImageURI(selectedImageUri);
}
}
in my application i fetch image from camera or gallery and save in imageview. now how can i save this imageview image as my contact picture image.
detail.java
camera.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
//gallery picture
galary.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
}
});
save.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent image= new Intent(Intent.)
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
photo1.setImageBitmap(photo);
}
else
{
if (data != null && resultCode == RESULT_OK)
{
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
if(photo != null && !photo.isRecycled())
{
photo = null;
}
photo = BitmapFactory.decodeFile(filePath);
photo1.setBackgroundResource(0);
photo1.setImageBitmap(photo);
}
else
{
Log.d("Status:", "Photopicker canceled");
}
}
}
}
setimage.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
Context context= getApplicationContext();
Bitmap icon= BitmapFactory.decodeResource(context.getResources(),
R.id.your_img_view);
try {
Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_ATTACH_DATA);
myIntent.setType("image/jpeg");
myIntent.putExtra(Intent.EXTRA_STREAM, icon);
startActivity(myIntent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
});
add:
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
in your manifest.
I have created the activity for taking picture using Builtin image Capture activity but still not available to store picture in sdcard and view the captured image.The Intent is started and i am able to take the picture but when i click on ok(save), nothing haappens. Below is my activity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.picturelayout);
imageForUpload = (ImageView) findViewById(R.id.trackMePicture);
btnBack = (Button) findViewById(R.id.btnBack);
intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri(this));
startActivityForResult(intent, TAKE_PHOTO_CODE);
}
/**
* #return
*/
private Uri getImageUri(Context context) {
// TODO Auto-generated method stub
File file =newFile(Environment.getExternalStorageDirectory(),context.getPackageName());
if(!file.exists())
file.mkdir();
File newFile=new File(file,new Date().toString()+".jpg");
Uri imagePath=Uri.fromFile(newFile);
return imagePath;
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==TAKE_PHOTO_CODE ){
if(resultCode==-1){
Toast.makeText(getApplicationContext(), "Result code : "+resultCode, Toast.LENGTH_LONG).show();
//Uri imagePath=getImageUri();
Bitmap b;
try {
b = Media.getBitmap(getContentResolver(), getImageUri(this));
imageForUpload.setImageBitmap(b);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
Toast.makeText(getApplicationContext(), "Result code : "+resultCode, Toast.LENGTH_LONG).show();
}
}
else{
Toast.makeText(getApplicationContext(), "Request code : "+requestCode, Toast.LENGTH_LONG).show();
}
}
There is no code in your onActivityResult() that would store the bitmap b in a file.
You can have a look at the PicHelper.storeBitmap() method from my Zwitscher app on how to do that.
Try doing this:
final Bundle extras = data.getExtras();
if (extras != null) {
Bitmap b = extras.getParcelable("data");
imageForUpload.setImageBitmap(b);
}
Here is how I do it (for taking picture or browsing the media directory), hope it can help:
static int SELECT_IMAGE = 2000;
static int CAMERA_REQUEST = 2001;
public void ProfilePictureDialog()
{
builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setMessage("").setPositiveButton("Browse images", new DialogInterface.OnClickListener()
{
#Override
public void onClick(DialogInterface dialog, int which)
{
Intent gallery = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(gallery, SELECT_IMAGE);
}}).setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
#Override
public void onClick(DialogInterface dialog, int which)
{
}}).setNeutralButton("Take picture with camera", new DialogInterface.OnClickListener(){
#Override
public void onClick(DialogInterface dialog, int which)
{
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}});
builder.show();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(resultCode == RESULT_OK)
{
if (requestCode == CAMERA_REQUEST)
{
Bitmap photo = (Bitmap) data.getExtras().get("data");
ImageView profilePicture = (ImageView) findViewById(R.id.profilepic);
photo = Bitmap.createScaledBitmap(photo, profilePicture.getWidth(), profilePicture.getHeight(), true);
profilePicture.setImageBitmap(photo);
}
else if(requestCode == SELECT_IMAGE)
{
Uri selectedImagePath = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImagePath, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
Bitmap photo = BitmapFactory.decodeFile(filePath);
ImageView profilePicture = (ImageView) findViewById(R.id.profilepic);
photo = Bitmap.createScaledBitmap(photo, profilePicture.getWidth(), profilePicture.getHeight(), true);
profilePicture.setImageBitmap(photo);
}
}
}