Reputation: 682
I followed the Android developers example of get an image form the camera intent and place it on your view. The problem starts when I try to save that image uri on my SqliteDatabase
( just the link to that image not the full image so I save space) and then I try to restore it on my customadapter.
Link to google dev - > http://developer.android.com/training/camera/index.html
I tried this without success
created a global string logo, and inside handleSmallCameraPhoto
put this
private void handleSmallCameraPhoto(Intent intent) {
Bundle extras = intent.getExtras();
mImageBitmap = (Bitmap) extras.get("data");
ImagenViaje.setImageBitmap(mImageBitmap);
ImagenViaje.setVisibility(View.VISIBLE);
--> logo = extras.get("data").toString();
Then I stored logo on SQLite, and tried to restore it on my adapter this way
String imagePath = c.getString(c.getColumnIndexOrThrow(MySQLiteHelper.COLUMN_LOGO_PATH));
Then
ImageView item_image = (ImageView) v.findViewById(R.id.logo);
item_image.setVisibility(ImageView.INVISIBLE);
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
item_image.setImageBitmap(bitmap);
item_image.setVisibility(ImageView.VISIBLE);
Upvotes: 1
Views: 2019
Reputation: 3858
get path of image using
Uri selectedImageUri = intent.getData();
String s1 = intent.getDataString();
String selectedImagePath = getPath(selectedImageUri);
if(selectedImagePath==null && s1 != null)
{
selectedImagePath = s1.replaceAll("file://","");
}
in your handleSmallCameraPhoto
method
add this method in your activity
public String getPath(Uri uri) {
try{
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
if(cursor==null)
{
return null;
}
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
catch(Exception e)
{
return null;
}
}
save selectedImagePath
in your database and use when you need selectedImagePath
is path of your selected image
hope help you..
Upvotes: 0