2011-08-05 15 views
1

인터넷에서 sdcard에 여러 이미지를 저장하고 데이터베이스에 경로를 저장하는 방법은 무엇입니까? 여러 이미지의 경우 어떻게해야합니까? 내가 한 지금 무슨 일이 될 때까지 ..데이터베이스에 이미지를 저장하는 방법

표 쿼리 아래는 생성 :

이 가 이

 bmOptions = new BitmapFactory.Options(); 
     bmOptions.inSampleSize = 1; 
     bm = Loadmage(image_URL, bmOptions); 

     mImageV.setImageBitmap(bm); 


     extStorageDirectory = Environment.getExternalStorageDirectory().toString(); 

     OutputStream outStream = null; 
      File file = new File(extStorageDirectory, "er.PNG"); 
      try{ 
      outStream = new FileOutputStream(file); 
      bm.compress(Bitmap.CompressFormat.PNG, 100, outStream); 
      outStream.flush(); 
      outStream.close(); 
      }catch (FileNotFoundException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 

그래서 모든 제목 같은 이미지가

하지만 하나 개의 값을 저장하기 위해 내가 삽입 한 것입니다

"create table table1 (_id integer primary key autoincrement, " 
        + "title text not null, definition text not null, image BLOB not null);"; 
로 보여주는 중 ... 다른 제목의 다른 이미지를 표시하고 싶습니다.

+2

문제가 있습니까? 하나의 레코드 당 하나의 경로를 데이터베이스에 저장합니까? db 테이블이 어떻게 생겼는지와 같은 질문에 좀 더 자세한 정보가 필요합니다. – aha

답변

1

서버의 이름으로 이미지의 이름을 사용해야합니다. 그냥 디렉토리에 이미지 이름 CONCAT 예를

에 대한

당신이 이미지 이름을 rose.jpg 을 원하는 경우 SD 카드에 저장할 가정해야 다음

File file = new File(Environment.getExternalStorageDirectory(), "/backup/" + rose.jpg); 

및 그러면 파일 이름의 경로를 저장할 수 있습니다.

String path = file.getAbsolutePath(); 
관련 문제