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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:55:34+00:00 2026-06-06T07:55:34+00:00

Hello Stackoverflowers! I created a simple sqlite DB like so. //event table name private

  • 0

Hello Stackoverflowers!

I created a simple sqlite DB like so.

//event table name
private static final String TABLE_EVENTS = "events";

//event table columns names
private static final String KEY_ID = "id";
private static final String KEY_EVENT = "event";

@Override
public void onCreate(SQLiteDatabase db) 
{
//String to define our database
String CREATE_EVENT_TABLE = "CREATE TABLE " + TABLE_EVENTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_EVENT + " TEXT" + ")";

//create our database
db.execSQL(CREATE_EVENT_TABLE);
}

Which I understand to be a table with an id column and an event column.

in the event column I am storing a JSONObject converted to a string which I would like to retrieve from the table in FIFO(First in First Out) order, so that if my application crashes I can send the JSONObjects that I have stored next time the app is opened.

I can insert to the table without a problem using:

public void addEvent(JSONObject event)
{
    //get our database so we can add to it
    SQLiteDatabase db = this.getWritableDatabase();

    //define content values to store our values
    ContentValues values = new ContentValues();

    //add our event to the ContentValues
    values.put(KEY_EVENT, event.toString());

    //insert a row
    db.insert(TABLE_EVENTS, null, values);

    //close the database connection
    db.close();
}

I am having trouble querying for a specific row or event and getting the event from the database as well as a good method to keep track the order in which the events were inserted, so that I can pull them out in a FIFO order.

Sample code is especially helpful seeing as when I try to query I am getting syntax errors, and am not very familiar with SQLite.

Any help is much appreciated! Thank you for your time.

  • 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-06T07:55:39+00:00Added an answer on June 6, 2026 at 7:55 am

    Hello VinC the best approach is to auto increment id, which is your primary key so you can do it by,

    String CREATE_EVENT_TABLE = "CREATE TABLE " + TABLE_EVENTS + "("
    + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_EVENT + " TEXT" + ")";
    

    Now you can query database with orderby Id in Ascending order

    database.query("TABLE_EVENTS", new String[]{"KEY_EVENT"},null,null, null, null,"KEY_ID ASC");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello stackoverflowers! This is my button: <Button android:layout_width=fill_parent android:layout_height=0dp android:layout_weight=0.30 android:text=@string/menu_button_newgame android:id=@+id/button_newgame /> when
Hello Stackoverflowers! I have written a relatively simple application that consists of a login
Story so far.... Hello Stackoverflowers, me again! Right, im learning JQuery at the moment
Hello dear Stackoverflowers ! I work on a CardDAV sync source for Android 2.3.3,
Hello fellow StackOverflowers. I'm have a brain fart right now, and I cannot seem
Hello guys I need to pass a string array over to a setter that
Database: name_ allmoney Table name: MONEY +-----+--------+------------+---------+---------+ | id | name | date |
Hello,I'd like to ask you two questions. (I am using java and jedis) I
Hello following problem, i need the id attribute string for each div in a
Hello wonderful stackoverflowers! I hope this question is within the scope of this site.

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.