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 8549931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:50:02+00:00 2026-06-11T13:50:02+00:00

This is my first time working with SQLite in the Android environment. I am

  • 0

This is my first time working with SQLite in the Android environment. I am trying to insert a photo and the coordinates of the user when the photo is taken, into an SQLite DB.

It seemed to have worked fine last night (Home Computer) when I tried to insert the photo into the DB, no exceptions, although I couldn’t find where the tablet was creating the DB, I tried looking in the data folder through the File Explorer in Eclipse DDMS but there was nothing in there, using the Windows file Explorer I have Computer\SCH-I905\Tablet\Android\data with com.app etc but my package is not present.

This morning (Work Computer) I am getting a fatal StackOverflowError exception. Is there something I am doing wrong with my code?? I am converting the image to byte[] then storing to the DB as a Blob, I am using the byte[] instead of converting the byte[] to String due to some recommendations I read against Strings to Blob. Any help or recommendation is MUCH appreciated, thanks.

P.S. I don’t have anything in my code converting string toUpperCase()


Background:

  • Google APIs 12
  • Testing on the Samsung Galaxy 10.1 4G LTE Tablet
  • I’m developing on two different computers (Home and Work), presently I copy files to a thumb drive then load them into my Workspace and start Eclipse. I have to uninstall the app due to conflicting signatures and then re-run the application through Eclipse.

Here I convert the image to byte[] then post to database:

public Camera.PictureCallback jpegHandler = new Camera.PictureCallback(){

    public void onPictureTaken(byte[] jpeg, Camera camera ){
        // TODO Work on the image insertion into the database

        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            image = BitmapFactory.decodeByteArray(jpeg, 0, jpeg.length);
            image.compress(Bitmap.CompressFormat.PNG, 100, bos);
            byte[] imageBlob = bos.toByteArray();

            UpdateGeoLocation updateGeo = new UpdateGeoLocation(getApplicationContext());

            double picLat = updateGeo.returnlocation.getLatitude();
            double picLng = updateGeo.returnlocation.getLongitude();

            Log.i("imageBlob", "" + imageBlob);
            Log.i("phoLat", "" + picLat);
            Log.i("phoLng", "" + picLng);

            dbControl.open();
            dbControl.addItem(imageBlob, picLat, picLng);
            dbControl.close();

            Log.i("InsertPhotoIntoDB", "WORKED!");
        } catch (SQLiteException e) {
            Log.e("InsertPhotoIntoDB", "FAILED: " + e.getMessage());
        }

Here is a snippet of my DatabaseHelper.Java

public class GlobalDBVars {
    public static final String DATABASE_NAME = "NST.db";
    public static final int DATABASE_VERSION = 2;
    public static final String TABLE_NAME = "photos_withCoordinates";

    public static final String KEY_ROWID = "_id";
    public static final String KEY_PHOTOS = "_photo";
    public static final String KEY_LAT = "_lat";
    public static final String KEY_LNG = "_lng";
}

private static final String DATABASE_CREATE = "CREATE TABLE IF NOT EXISTS " + 
    GlobalDBVars.TABLE_NAME + "(" + 
    GlobalDBVars.KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
    GlobalDBVars.KEY_PHOTOS + " BLOB NOT NULL, " + 
    GlobalDBVars.KEY_LAT + " REAL NOT NULL, " + 
    GlobalDBVars.KEY_LNG + " REAL NOT NULL);";

@Override
public void onCreate(SQLiteDatabase db) {
    try {
        db.execSQL(DATABASE_CREATE);
        onCreate(db);
        Log.i(TAG, "onCreate db: " + DATABASE_CREATE);
    } catch (SQLException e) {
        Log.e(TAG, "FAILED: " + e.getMessage());
    }
}

Insert statement within DatabaseControl.Java

public long addItem(byte[] photos, double _lat, double _lng) {
    ContentValues setUpVals = createContentValues(photos, _lat, _lng);

    return database.insert(GlobalDBVars.TABLE_NAME, null, setUpVals);
}

LogCat:

09-04 10:08:48.160: I/imageBlob(21529): [B@40751c18
09-04 10:08:48.160: I/phoLat(21529): 37.3674153
09-04 10:08:48.160: I/phoLng(21529): -77.4001403
09-04 10:08:48.240: I/dalvikvm(21529): threadid=1: stack overflow on call to Ljava/util/Locale;.getLanguage:L
09-04 10:08:48.240: I/dalvikvm(21529):   method requires 8+20+0=28 bytes, fp is 0x58f53318 (24 left)
09-04 10:08:48.240: I/dalvikvm(21529):   expanding stack end (0x58f53300 to 0x58f53000)
09-04 10:08:48.240: I/dalvikvm(21529): Shrank stack (to 0x58f53300, curFrame is 0x58f56d8c)
09-04 10:08:48.240: D/AndroidRuntime(21529): Shutting down VM
09-04 10:08:48.240: W/dalvikvm(21529): threadid=1: thread exiting with uncaught exception (group=0x40105760)
09-04 10:08:48.270: D/dalvikvm(21529): GC_CONCURRENT freed 95K, 8% free 8606K/9287K, paused 2ms+2ms
09-04 10:08:48.310: E/AndroidRuntime(21529): FATAL EXCEPTION: main
09-04 10:08:48.310: E/AndroidRuntime(21529): java.lang.StackOverflowError
09-04 10:08:48.310: E/AndroidRuntime(21529):    at java.lang.CaseMapper.toUpperCase(CaseMapper.java:143)
09-04 10:08:48.310: E/AndroidRuntime(21529):    at java.lang.String.toUpperCase(String.java:1619)
09-04 10:08:48.310: E/AndroidRuntime(21529):    at android.database.DatabaseUtils.getSqlStatementType(DatabaseUtils.java:1245)
09-04 10:08:48.310: E/AndroidRuntime(21529):    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:100)
09-04 10:08:48.310: E/AndroidRuntime(21529):    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:59)
09-04 10:08:48.310: E/AndroidRuntime(21529):    at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1931)
09-04 10:08:48.310: E/AndroidRuntime(21529):    at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1864)
09-04 10:08:48.310: E/AndroidRuntime(21529):    at sompackage.nst.DatabaseHelper.onCreate(DatabaseHelper.java:49)
  • 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-06-11T13:50:03+00:00Added an answer on June 11, 2026 at 1:50 pm

    You’re calling onCreate() recursively

    @Override
    public void onCreate(SQLiteDatabase db) {
        try {
            db.execSQL(DATABASE_CREATE);
            **onCreate(db);**
    ...
    }
    

    Remove that onCreate(db) call

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

Sidebar

Related Questions

This is my first time working with python. I'm trying to create a dictionary
This is my first time working with localStorage, and I'm trying to store a
This is my first time working with regular expressions and I've been trying to
This is my first time working with Quartz. I am trying out a sample
i am working with sqlite database in Android for first time. i have create
This is my first time working with GAE and I'm trying to get CDI
This is my very first time working with SSE intrinsics. I am trying to
This is my first time working with a WPF datagrid. From what I understand
This is my first time working with file i/o in java, and it's not
this is my first time asking a question on stackoverflow. I'm working on a

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.