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

  • Home
  • SEARCH
  • 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 841943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:52:51+00:00 2026-05-15T05:52:51+00:00

Hey everyone. I’m kinda new to android programming so please bear with me. I’m

  • 0

Hey everyone. I’m kinda new to android programming so please bear with me. I’m having some problems with retrieving records from the db. Basically, all I want to do is to store latitudes and longitudes which GPS positioning functions outputs and display them in a list using ListActivity on different tab later on. This is how the code for my DBAdapter helper class looks like:

public class DBAdapter 
{
    public static final String KEY_ROWID = "_id";
    public static final String KEY_LATITUDE = "latitude";
    public static final String KEY_LONGITUDE = "longitude";
    private static final String TAG = "DBAdapter";

    private static final String DATABASE_NAME = "coords";
    private static final String DATABASE_TABLE = "coordsStorage";
    private static final int DATABASE_VERSION = 1;

    private static final String DATABASE_CREATE =
        "create table coordsStorage (_id integer primary key autoincrement, "
        + "latitude integer not null, longitude integer not null);";

    private final Context context; 

    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;

    public DBAdapter(Context ctx) 
    {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }

    private static class DatabaseHelper extends SQLiteOpenHelper 
    {
        DatabaseHelper(Context context) 
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

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

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, 
        int newVersion) 
        {
            Log.w(TAG, "Upgrading database from version " + oldVersion 
                    + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS titles");
            onCreate(db);
        }
    }    

    //---opens the database---
    public DBAdapter open() throws SQLException 
    {
        db = DBHelper.getWritableDatabase();
        return this;
    }

    //---closes the database---    
    public void close() 
    {
        DBHelper.close();
    }

    //---insert a title into the database---
    public long insertCoords(int latitude, int longitude) 
    {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_LATITUDE, latitude);
        initialValues.put(KEY_LONGITUDE, longitude);
        return db.insert(DATABASE_TABLE, null, initialValues);
    }

    //---deletes a particular title---
    public boolean deleteTitle(long rowId) 
    {
        return db.delete(DATABASE_TABLE, KEY_ROWID + 
                "=" + rowId, null) > 0;
    }

    //---retrieves all the titles---
    public Cursor getAllTitles() 
    {
        return db.query(DATABASE_TABLE, new String[] {
                KEY_ROWID, 
                KEY_LATITUDE,
                KEY_LONGITUDE}, 
                null, 
                null, 
                null, 
                null, 
                null);
    }

    //---retrieves a particular title---
    public Cursor getTitle(long rowId) throws SQLException 
    {
        Cursor mCursor =
                db.query(true, DATABASE_TABLE, new String[] {
                        KEY_ROWID,
                        KEY_LATITUDE, 
                        KEY_LONGITUDE}, 
                        KEY_ROWID + "=" + rowId, 
                        null,
                        null, 
                        null, 
                        null, 
                        null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

    //---updates a title---
    /*public boolean updateTitle(long rowId, int latitude, 
    int longitude) 
    {
        ContentValues args = new ContentValues();
        args.put(KEY_LATITUDE, latitude);
        args.put(KEY_LONGITUDE, longitude);
        return db.update(DATABASE_TABLE, args, 
                         KEY_ROWID + "=" + rowId, null) > 0;
    }*/
}

Now my question is – am I doing something wrong here? If yes could someone please tell me what? And how I should retrieve the records in organised list manner? Help would be greatly appreciated!!

This are the error it throws:

06-06 14:49:32.434: ERROR/Database(276): Error inserting latitude=0 longitude=0
06-06 14:49:32.434: ERROR/Database(276): android.database.sqlite.SQLiteException: no such table: coordsStorage: , while compiling: INSERT INTO coordsStorage(latitude, longitude) VALUES(?, ?);
06-06 14:49:32.434: ERROR/Database(276):     at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
06-06 14:49:32.434: ERROR/Database(276):     at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
06-06 14:49:32.434: ERROR/Database(276):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
06-06 14:49:32.434: ERROR/Database(276):     at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:41)
06-06 14:49:32.434: ERROR/Database(276):     at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:925)
06-06 14:49:32.434: ERROR/Database(276):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1300)
06-06 14:49:32.434: ERROR/Database(276):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1173)
06-06 14:49:32.434: ERROR/Database(276):     at tabs.app.DBAdapter.insertCoords(DBAdapter.java:81)
06-06 14:49:32.434: ERROR/Database(276):     at tabs.app.Tribocracy$1.onClick(Tribocracy.java:118)
06-06 14:49:32.434: ERROR/Database(276):     at android.view.View.performClick(View.java:2344)

and then when I’m trying to retrieve it it throws this:

06-06 14:49:52.734: INFO/Process(51): Sending signal. PID: 276 SIG: 3
06-06 14:49:52.734: INFO/dalvikvm(276): threadid=7: reacting to signal 3
06-06 14:49:52.734: ERROR/dalvikvm(276): Unable to open stack trace file /data/anr/traces.txt': 
Permission denied
  • 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-15T05:52:52+00:00Added an answer on May 15, 2026 at 5:52 am

    It looks like the table doesn’t exist for some reason.

    You may want to try increasing your version number, to force an upgrade; if the database itself exists then the onCreate method won’t be called – increasing the version will force onUpgrade to be called, and your implementation drops the table and recreates it. This should either fix your error, or give you a new error to work with!

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

Sidebar

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.