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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:34:29+00:00 2026-06-03T12:34:29+00:00

This is the calling file: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); dbActivities

  • 0

This is the calling file:

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    dbActivities = new DBActivities(this);
    dbActivities.open();    // Create or open the existing DB if already created
}

private final BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
                smsCount++;
                Log.d(LOG_TAG, "smsCount=" +smsCount);
                long dbInsertReturn = dbActivities.insertIntoDB(smsCount);
            }
        }
};

This is the file that does the actual DB operations:

public class DBActivities {
    private static final String LOG_TAG = "SMSCounterActivity";

    private static final String DATABASE_NAME = "sms_details_database";
    private static final String DATABASE_TABLE = "sms_details_table";
    private static final String KEY_DATE = "date";
    private static final String KEY_SMS_CURRENT_COUNT = "sms_current_count";
    private static final String CREATE_SMS_DETAILS_TABLE = "CREATE TABLE " + DATABASE_TABLE + "(" + KEY_DATE + " TEXT, " + KEY_SMS_CURRENT_COUNT + " INTEGER);";
    private static final int DATABASE_VERSION = 1;

    private final Context mContext;
    private DatabaseHelper mDbHelper;
    private SQLiteDatabase mDb;

    public DBActivities(Context param_context) {
        this.mContext = param_context;
    }

    // Database helper class for creating and updating database
     private static class DatabaseHelper extends SQLiteOpenHelper {
         DatabaseHelper(Context context) {
             super(context, DATABASE_NAME, null, DATABASE_VERSION);
         }

         @Override
         public void onCreate(SQLiteDatabase db) {
             Log.i(LOG_TAG, "Creating DataBase: " + CREATE_SMS_DETAILS_TABLE);
             db.execSQL(CREATE_SMS_DETAILS_TABLE);
         }

         @Override
         public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
             Log.w(LOG_TAG, "Upgrading database from version " + oldVersion + " to " + newVersion);
         }
     }

     // Create a new DB. If DB already exists, open it !
    public DBActivities open() throws SQLException {
        Log.d(LOG_TAG, "Trying to open DB now. Table query=" + CREATE_SMS_DETAILS_TABLE);
        mDbHelper = new DatabaseHelper(mContext);
        mDb = mDbHelper.getWritableDatabase();
        return this;
    }

    public void close() {
        mDbHelper.close();
    }

    // DB format: date | sms_current_count
    // date = YYYY-MM-DD
    public long insertIntoDB (int db_value_to_insert) {
        ContentValues dbValues = new ContentValues();
        dbValues.put(KEY_DATE, getCurrentDate());
        dbValues.put(KEY_SMS_CURRENT_COUNT, db_value_to_insert);
        return mDb.insert(DATABASE_TABLE, null, dbValues);
    }

    private String getCurrentDate() {
        Calendar calendar = Calendar.getInstance();
        String currentDate = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH)+1) + "-" + calendar.get(Calendar.DAY_OF_MONTH);
        Log.d(LOG_TAG, "currentDate=" +currentDate);
        return currentDate;
    }
}

This is the logcat log:

05-09 01:52:33.363: D/SMSCounterActivity(444): Trying to open DB now. Table query=CREATE TABLE sms_details_table(date TEXT, sms_current_count INTEGER);
05-09 01:54:30.472: D/SMSCounterActivity(444): smsCount=1
05-09 01:54:30.482: D/SMSCounterActivity(444): currentDate=2012-5-9
05-09 01:54:30.592: I/Database(444): sqlite returned: error code = 1, msg = table sms_details_table has no column named sms_current_count
05-09 01:54:30.612: E/Database(444): Error inserting sms_current_count=1 date=2012-5-9
05-09 01:54:30.612: E/Database(444): android.database.sqlite.SQLiteException: table sms_details_table has no column named sms_current_count: , while compiling: INSERT INTO sms_details_table(sms_current_count, date) VALUES(?, ?);
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1536)
05-09 01:54:30.612: E/Database(444):    at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1410)
05-09 01:54:30.612: E/Database(444):    at com.android.main.DBActivities.insertIntoDB(DBActivities.java:66)
05-09 01:54:30.612: E/Database(444):    at com.android.main.SMSCounterActivity$1.onReceive(SMSCounterActivity.java:52)
05-09 01:54:30.612: E/Database(444):    at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:892)
05-09 01:54:30.612: E/Database(444):    at android.os.Handler.handleCallback(Handler.java:587)
05-09 01:54:30.612: E/Database(444):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 01:54:30.612: E/Database(444):    at android.os.Looper.loop(Looper.java:123)
05-09 01:54:30.612: E/Database(444):    at android.app.ActivityThread.main(ActivityThread.java:4627)
05-09 01:54:30.612: E/Database(444):    at java.lang.reflect.Method.invokeNative(Native Method)
05-09 01:54:30.612: E/Database(444):    at java.lang.reflect.Method.invoke(Method.java:521)
05-09 01:54:30.612: E/Database(444):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-09 01:54:30.612: E/Database(444):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-09 01:54:30.612: E/Database(444):    at dalvik.system.NativeStart.main(Native Method)

I am not able to figure out why the DB insertion is failing. logcat shows that that the table creation query is normal. Still sms_current_count column is missing in the table.

  • 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-03T12:34:32+00:00Added an answer on June 3, 2026 at 12:34 pm

    Usually when your create script is fine and there’s a column that doesn’t exist in the db it’s because you changed the schema without incrementing the db version. If this is the case, the only thing wrong with your CREATE script is that it has not been run yet

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

Sidebar

Related Questions

The browser does this by calling public void emulateShiftHeld() method on the WebView which
My problem: I have 3 templates: main.html.twig (main layout file) layout.html.twig (a bundle specific
alt text http://img179.imageshack.us/img179/7827/textwriter.jpg the tf.txt file has 0 bytes and when calling this method
Hi I'm calling this function: function getCoordenadas() { var coordenadas = new Array(); $.post(
I am calling this from a function by creating an object.The progress box appears
I need this for calling a C function from Java class (JNI) and I
According to this website calling removeChild() in JavaScript causes an Internet Explorer Specific leak
so live docs says this for calling .lenght() on an XML object For XML
I have a function like this: MyFunction(double matrix[4][4]) {/*do stuff*/} I am calling this
I am getting this error when calling a web service method which writes to

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.