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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:16:00+00:00 2026-05-27T12:16:00+00:00

In my android app I had one class doing the following functions: storing data

  • 0

In my android app I had one class doing the following functions:
storing data from an XML source into a database;
loading the data from the database;
rewriting to the database from the xml source if the data was more than 24 hours old;
that all worked fine.

I am now trying to write a new table to that same database from another class.
So I followed the same procedures/set-up as in the first class and now the program crashes (force close error) and the android log cat gives the following errors:
SQL error: msg= table “table-name” does not exist
error inserting (query) into table “table-name” (this error is repeated for each insert attempted)

The problem is, the “table-name” it gives me (saying it doesn’t exist) is the table from the first class which worked fine before.

Here is some relevant code:

public class CurrencyConverter {
public static String XML_SOURCE = "http://rss.timegenie.com/forex.gz";
public static long LAST_UPDATE=0;
private static SQLiteHelper.DatabaseAdapter dbAdapter;
private final static String TBL_NAME = "tbl_currency";
private final static String KEY_CODE = "code";
private final static String KEY_DESC = "description";
private final static String KEY_RATE = "rate";

private final static void createOrOpenDB(Context context) {
    SQLiteHelper dbHelper = new SQLiteHelper();
    TableObjectMaker tableObjs = dbHelper.new TableObjectMaker();
    tableObjs.addTable(TBL_NAME, new String[] {
             "_id integer primary key autoincrement",
             KEY_CODE + " text not null",
             KEY_DESC + " text not null",
             KEY_RATE + " real not null"
             });
    dbAdapter = dbHelper.new DatabaseAdapter(context);
    dbAdapter.open(tableObjs, "local_data", 1);
}
private final static void writeToDB(NodeList nodes) {
    if (nodes==null) return;
    List<ContentValues> content = SQLiteHelper.getContentValues(nodes,
            new String[] {KEY_CODE,KEY_DESC,KEY_RATE});
    for (ContentValues c:content) {
        dbAdapter.insertRowInTable(TBL_NAME, c);
    }
}
private final static void closeDB() {
    dbAdapter.close();
}
public static void updateDB(Context context) {
    Document xmlDocument = GZip.getResourceAsXML(XML_SOURCE,true);
    NodeList nodes = xmlDocument.getElementsByTagName("data");
    createOrOpenDB(context);
    writeToDB(nodes);
    closeDB();
    LAST_UPDATE = Calendar.getInstance().getTimeInMillis();
}
...
}  

The other class has identical database access/write methods as above, except with its own table name and field names, and it uses the same “local_data” name for the database name.
How can I get both classes to read and write to their own table in the same database?

  • 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-27T12:16:00+00:00Added an answer on May 27, 2026 at 12:16 pm

    Move all access to the data base into a ContentProvider. Each class can then interact with the ContentProvider, which then interacts with the database.

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

Sidebar

Related Questions

i've developed an android app that's fetches an xml file and displays this data
i am new user of android and i had make one android database connection
Am new to android development. I had created one android app and for that
I am writing an android app. I want to pass some data across the
In the test project for my android app I initially had a series of
I am developing an android app. Before releasing it to the market I had
My app had been chugging along fine on the Android market until last night
I am implementing Google analytic into my android app and I have got all
My Android app is crashing with this error: E/AndroidRuntime( 315): Caused by: android.database.sqlite.SQLiteException: bind
I'm working on my first android app and have an SQLite database set up

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.