1

I want to store a video file in sqlite database and retrieve it from the database. I can store it in database with code that I have.

FileInputStream fileInputStream = new FileInputStream("/sdcard/download/video.mp4");
byte[] image = new byte [fileInputStream.available()];
fileInputStream.read(image);

ContentValues valuse = new ContentValues();
valuse.put("a",image);
db.insert("tb",null,valuse);
fileInputStream.close();

And I want to retrieve it from database and play it.

Amir
  • 11
  • 1

1 Answers1

0

Storing a movie in a SQLite database (or any other database actually) is a bad idea from my experience.

What you can do instead is save the video file on your device and save the path to this file in the database.

Another solution is to store your videos online and load them from your online cloud this way:

String LINK = "http://www.yourcloud.com/yourideo.mp4";
setContentView(R.layout.mediaplayer);
VideoView videoView = (VideoView) findViewById(R.id.video);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();

But for sure DONT store videos in the database.

FlyingNades
  • 432
  • 3
  • 16