Uri tempUri = getImageUri(getApplicationContext(), bitmap);
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
Bitmap bitmap = ((BitmapDrawable)youImageView.getDrawable()).getBitmap();
: fooobar.com/questions/26543/...
File finalFile = new File(getRealPathFromURI(tempUri));
public String getRealPathFromURI(Uri uri) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
return cursor.getString(idx);
}
In my experience with Android, the only need I have ever had was that I started working on the Twitter4J SDK and TwitPic API. TwitPic needs the absolute path of the image you want to download. It was the best solution I found (a combination of several different solutions actually), but it always worked like a charm. Hope this helps you.
source
share