2011-09-05 5 views
0

Android에서 새로 생겼습니다. 로컬 (즉, SharedPreferences)의 이미지 (갤러리 또는 갤러리의 고정 사진에서 선택한 이미지)를 로컬에 저장하려고합니다. 응용 프로그램이 장치에서 실행될 때까지 이미지를 저장하고 싶습니다. 응용 프로그램이 장치에서 제거되면 모든 데이터가 제거됩니다.이미지를 Android에 로컬 저장

아무도 도와 줄 수 있습니까?

감사합니다. 당신은 자세한 내용을 추가해야

+0

... 당신이 약이 ** BTW, 안드로이드 서비스를 보면 ... ** s의 다음 이미지를 이미지를 포착하고 말한다. .. 만약 당신이 원한다면 당신의 어플리케이션은 그것이 실행되지 않았을 때라도 이미지를 저장합니다. – Whiler

답변

0

전화 저장이 기능 ..

void saveImage() { 

File myDir=new File("/sdcard/saved_images"); 
    myDir.mkdirs(); 

    String fname = "Image.jpg"; 
    File file = new File (myDir, fname); 
    if (file.exists()) file.delete(); 
    try { 
      FileOutputStream out = new FileOutputStream(file); 
      finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); 
      out.flush(); 
      out.close(); 
      final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
       alertDialog.setTitle("Save"); 
       alertDialog.setMessage("Your drawing had been saved:)"); 
       alertDialog.setButton("OK", new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 
        return; 
       } 
      }); 
      alertDialog.show(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
    } 
} 
관련 문제