Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6231745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:59:19+00:00 2026-05-24T09:59:19+00:00

First post here, so please bear with me if I get something wrong. I’m

  • 0

First post here, so please bear with me if I get something wrong.

I’m trying to store images for an application in an sqlite database. The images should be stored as blobs (is this a bad idea?). The code to do so looks like this:

public long createPicture(String title, byte [] thumb, byte [] imageData) {
    ContentValues data = new ContentValues();
    data.put(T_KEY_TITLE, title);            
    data.put(T_KEY_CONTENT, imageData);       // <-- blob in the db 
    data.put(T_KEY_THUMB, thumb);

    // db is an SQLiteDatabase
    return db.insert(TABLE_PICS, null, data); // <-- Crash occurs on this line
}

This code works perfectly well for the most part, but when I try to store large pictures (5 megapixels from the built in camera) it crashes. Not only does it crash, it also screws up the database so that the app crashes whenever I try to launch it again.

So my question is: is there any way to get around this, or should I put the large pictures as files and just store the path? Also, I’d love to get some general guidelines on when to use sqlite and when to just go for files.

Thanks! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:59:20+00:00Added an answer on May 24, 2026 at 9:59 am

    For storing images, the usual and best practice is to store them externally (to an SD card, or some other means of external storage). getExternalStorageDirectory() will provide you with a location to store your large files, or getExternalFilesDir() if you’re API 8 and above.

    The database transaction could be having any number of things go wrong (insufficient space, transaction timeout, etc.). It’s probably best to store the URI of the image in the DB, then place the actual image into an external location.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, please see this post on Doctype I've been trying to get an answer
This is my first post here and I wanted to get some input from
My first post here, please be gentle. =) I work for a company that
This is my first post in any forum so please bear with me. I
This is my first post, so please bear with me. I'll try and be
Okay this is my first post here so please forgive me if i mess
First post here... I normally develop using PHP and Symfony with Propel and ActionScript
first post here, and probably an easy one. I've got the code from Processing's
first post here, I come in peace :) I've searched but can't quite find
My first post here, so i hope this is the right area. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.