2012-01-30 72 views
0

其實我已經檢索到保存在Facebook上的圖像,但我沒有得到如何保存圖像到我的模擬器並獲取保存的圖像的路徑位置,因爲我必須保存路徑在sqlite。 在大多數計算器答案的,它只是描述關於保存圖像而不是緊靠檢索路徑保存一個圖像,並在android模擬器上獲取圖像的保存位置

imageURL = "http://graph.facebook.com/"+id+"/picture?type=small"; 
bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent()); 
String extStorageDirectory = Environment.getExternalStorageDirectory().toString(); 
File file = new File(extStorageDirectory, fileName+".jpg"); 
file.createNewFile(); 
FileOutputStream fos = new FileOutputStream(file); 
bitmap.compress(CompressFormat.JPEG, 75, fos); 
fos.flush(); 
fos.close(); 

,我甚至已經更新了我的清單文件

uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 

回答

0

使用此片段希望這將解決您的問題

MediaStore.Images.Media.insertImage(getContentResolver(), bitmapimage, 
barcodeNumber + ".jpg Card Image", barcodeNumber 
+ ".jpg Card Image"); 
+1

沒錯akki,我認爲它能夠更好地保存像this.But圖像在此之後我將如何檢索圖像location.Thanks對您有所幫助。 – 2012-01-30 08:19:51

+0

@Shahzadimam:它會以字符串形式返回uri,您可以使用它來到那裏。 – Akram 2012-01-30 10:44:36

1

您的file對象已經擁有該信息。

得到這樣說:

file.getAbsolutePath() 
+0

是的,這是正確的獲取位置。但現在我已經改變了方法根據Akki。現在我將如何獲得圖像位置?謝謝無聲............ – 2012-01-30 08:22:11