Lingviston이 이미 지적한대로. here 갤러리에서 이미지 선택을 구현할 수 있습니다.
이미지 저장에 관해서는 링크의 코드를 조금 편집하겠습니다. 대신이의
:
ImageView imageView = (ImageView) findViewById(R.id.imgView);
imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
가 나는 Bitmap
에서 선택한 이미지를 저장하는거야.
ImageView imageView = (ImageView) findViewById(R.id.imgView);
Bitmap mBitmap = BitmapFactory.decodeFile(picturePath);
imageView.setImageBitmap(mBitmap);
은 이제 바이트로 비트 맵 변환하고 SQLite는 데이터베이스에 바이트 배열을 저장할 필요가 안드로이드에
BLOB
형태로 저장합니다.
ByteArrayOutputStream stream = new ByteArrayOutputStream();
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] imageInByte = stream.toByteArray();
지금 당신은 단지
SQLite
데이터베이스에 저장
imageInByte
을 통과해야합니다.
두 가지 대답은 이미 인터넷과 StackOverflow
에서 사용할 수 있었기 때문에 2와 2를 함께 사용해야했습니다. 질문을 게시하기 전에 철저히 검색하십시오.
http://viralpatel.net/blogs/pick-image-from-galary-android-app/ 또한 MediaStore 콘텐츠 공급자를 통해 대부분의 모든 mesia 데이터에 액세스 할 수 있습니다. – Lingviston
매우 유용합니다. 감사합니다. – moictab