答案 0 :(得分:2)
答案 1 :(得分:1)
为此,您应该使用MediaStore API
String yourImageFilename= String.valueOf(System.currentTimeMillis()); //using this for simplicity
ContentValues cValues = new ContentValues();
cValues.put(Images.Media.TITLE, yourImageFilename);
cValues.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
cValues.put(Images.Media.MIME_TYPE, "image/jpeg"); //your image type here, jpg for sample
Uri uri = context.getContentResolver().insert(Images.Media.INTERNAL_CONTENT_URI, values);
try {
OutputStream outStream = context.getContentResolver().openOutputStream(uri);
Url imageResource = new Url("your url string");
Bitmap mBitmap = BitmapFactory.decodeStream(imageResource.openStream());
mBitmap.compress(Bitmap.CompressFormat.JPEG, 90, outStream); //if you want to compress the jpg
outStream.flush();
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
我假设您在本地数据库中有意思(可以在图库中查看,如果没有,请将您的问题编辑为更具体)。