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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:03:37+00:00 2026-06-17T07:03:37+00:00

I am attempting my first use of Sqlite in Android with mixed results. In

  • 0

I am attempting my first use of Sqlite in Android with mixed results.

In my first activity I load a number of rows into a table using code like this

public void addTableStatus(String tableId, String name) {

    Log.d("DB", "Before Insert :: " + "Id=[" + tableId + "]");

    if (sd == null) {
        Log.d("DB", "Get Database");
        sd = getWritableDatabase();
    }

    ContentValues cv = new ContentValues();
    cv.put(V2VocabsTable.ID, tableId);
    cv.put(V2VocabsTable.NAME, name);
    cv.put(V2VocabsTable.LOADED, "NO");

    long result = sd.insert(V2VocabsTable.TABLE_NAME, null, cv);

    Log.d("DB", "After Insert :: " + result);

    String query = "SELECT * from " + V2VocabsTable.TABLE_NAME ;

    Log.i("DB2", "Query    : " + query);
    Cursor mCursor = sd.rawQuery(query, null);
    Log.i("DB2", "Result : " + mCursor.getCount());
}

The log file shows data going in as follows :

01-13 21:54:09.788: D/DB(22744): Before Insert :: Id=[ZU055]
01-13 21:54:09.798: D/DB(22744): After Insert :: 129
01-13 21:54:09.798: I/DB2(22744): Query    : SELECT * from v2TableStatus
01-13 21:54:09.798: I/DB2(22744): Result : 129
01-13 21:54:09.798: D/DB(22744): ZU055 :: WaitingListType-v1.0.xml
01-13 21:54:09.798: D/DB(22744): Before Insert :: Id=[ZU056]
01-13 21:54:09.798: D/DB(22744): After Insert :: 130
01-13 21:54:09.798: I/DB2(22744): Query    : SELECT * from v2TableStatus
01-13 21:54:09.798: I/DB2(22744): Result : 130
01-13 21:54:09.798: D/DB(22744): ZU056 :: DCRConsentToShareIndicator-v1.0.xml

However when I try to read the table in another activity there does not seem to be any data in the table. I execute the same query (as a test) and always get 0 rows.

public void test(String tableName) {

    if (sd == null) {
        sd = getWritableDatabase();
    }

    tableName = tableName.substring(5).trim();

    String query;

    Log.i("DB_", "Test for : [" + tableName + "]");

    query = "SELECT * from " + V2VocabsTable.TABLE_NAME ;

    Log.i("DB2", "Query    : " + query);
    Cursor mCursor = sd.rawQuery(query, null);
    Log.i("DB2", "Result : " + mCursor.getCount());
}


01-13 21:54:18.838: I/DB_(22744): Test for : [0136]
01-13 21:54:18.838: I/DB2(22744): Query    : SELECT * from v2TableStatus
01-13 21:54:18.838: I/DB2(22744): Result : 0
  • 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-17T07:03:38+00:00Added an answer on June 17, 2026 at 7:03 am

    My mistake, my dbHelper class was erroneously clearing the tables down when it initiated. So when it initiated in the second activity it removed all of the content placed in it from the first activity.

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

Sidebar

Related Questions

I am attempting to use EF with Code First and the Web API. I
I'm attempting to use a form post to add rows to a mySQL table.
This is the first time I'm attempting to use NUnit. I've installed NUnit into
First off i want to say im attempting (and mostly succeeding) to use purely
I am attempting to make my first mobile website by just using a different
I am attempting to store NSMutableDictionaries as a blobs in sqlite, by first converting
I am trying to start using cython and and attempting to compile my first
I'm attempting to use fabric for the first time and I really like it
I am attempting to use an existing stored procedure to populate a gridview. First,
First of all, I'm attempting to use faux namespaces in my JavaScript program like

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.