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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:36:03+00:00 2026-05-28T01:36:03+00:00

My application is using a bootup service.In the service i have to get values

  • 0

My application is using a bootup service.In the service i have to get values from a database,but the app is crashing as it tries getting the values…

The logcat error is listed below………..

01-03 22:19:46.097: E/AndroidRuntime(240): FATAL EXCEPTION: main
01-03 22:19:46.097: E/AndroidRuntime(240): java.lang.RuntimeException: Unable to create service com.android.antitheft.MyService: java.lang.IllegalStateException: get field slot from row 0 col -1 failed
01-03 22:19:46.097: E/AndroidRuntime(240): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2969)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.app.ActivityThread.access$3300(ActivityThread.java:125)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.os.Handler.dispatchMessage(Handler.java:99)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.os.Looper.loop(Looper.java:123)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-03 22:19:46.097: E/AndroidRuntime(240): at java.lang.reflect.Method.invokeNative(Native Method)
01-03 22:19:46.097: E/AndroidRuntime(240): at java.lang.reflect.Method.invoke(Method.java:521)
01-03 22:19:46.097: E/AndroidRuntime(240): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-03 22:19:46.097: E/AndroidRuntime(240): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-03 22:19:46.097: E/AndroidRuntime(240): at dalvik.system.NativeStart.main(Native Method)
01-03 22:19:46.097: E/AndroidRuntime(240): Caused by: java.lang.IllegalStateException: get field slot from row 0 col -1 failed
01-03 22:19:46.097: E/AndroidRuntime(240): at android.database.CursorWindow.getString_native(Native Method)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.database.CursorWindow.getString(CursorWindow.java:329)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
01-03 22:19:46.097: E/AndroidRuntime(240): at com.android.antitheft.MyService.onCreate(MyService.java:69)
01-03 22:19:46.097: E/AndroidRuntime(240): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2959)
01-03 22:19:46.097: E/AndroidRuntime(240): … 10 more

Thanx in advance…………..

my service.java //file

package com.android.antitheft;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.IBinder;
import android.telephony.TelephonyManager;
import android.telephony.SmsManager;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service {

SQLiteDatabase myDB;

@Override
public IBinder onBind(Intent arg0) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public void onCreate() {
    super.onCreate();
    System.out.println("@@@@@@@@@@@OnCreate1111");
    Toast.makeText(this, "Service Created", Toast.LENGTH_LONG).show();


      myDB = MyService.this.openOrCreateDatabase("antitheft", MODE_PRIVATE, null);
        Cursor cursor1 = myDB.query("SimSerial", null, null, null, null, null, null);
     cursor1.moveToLast();
        //cursor1.moveToFirst();
        String ss1 = cursor1.getString(cursor1.getColumnIndex("simno"));
        Toast.makeText(this, "FROM DATABASE: SIM SERIAL "+ss1, Toast.LENGTH_LONG).show();
        cursor1.close();
        myDB.close();



//          cursor2.moveToNext();
//          String num2 = cursor2.getString(cursor2.getColumnIndex("secure"));
//          
//          cursor2.moveToNext();
//          String num3 = cursor2.getString(cursor2.getColumnIndex("secure"));  

        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String ss=tm.getSimSerialNumber();

        Log.v("SERVICE", ss);

        Toast.makeText(this, "Service started : SIM SERIAL "+ss, Toast.LENGTH_LONG).show();

        Log.v("StartServiceAtBoot", "StartAtBootService -- onStartCommand()");          



        if(ss.equals(ss1))
        {
            SmsManager sms = SmsManager.getDefault();

//              sms.sendTextMessage("5556", null, "message", null, null);

            Toast.makeText(this, "INSIDE iffffffffffff ", Toast.LENGTH_LONG).show();
             myDB = MyService.this.openOrCreateDatabase("antitheft", MODE_PRIVATE, null);
            Cursor cursor2 = myDB.query("SimSerial", null, null, null, null, null, null);

            cursor2.moveToFirst();
            while (cursor2.isAfterLast() == false) {
                String num1 = cursor2.getString(cursor2.getColumnIndex("secure"));
                sms.sendTextMessage(num1, null, "message", null, null);
                cursor2.moveToNext();
            }
            cursor2.close();

            myDB.close();

//              sms.sendTextMessage(num1, null, "message", null, null);  
//              sms.sendTextMessage(num2, null, "message", null, null);
//              sms.sendTextMessage(num3, null, "message", null, null);
            }

//          else
//              
//          {
//              SmsManager sms = SmsManager.getDefault();
//              sms.sendTextMessage("5556", null, "message", null, null);
//              
//              Toast.makeText(this, "INSIDE elseeeeeeeeeeeeee", Toast.LENGTH_LONG).show();
//          }


}

@Override
public void onDestroy() {
    super.onDestroy();

    Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();

}

 @Override
    public int onStartCommand(Intent intent, int flags, int startId) 
    {



        // We want this service to continue running until it is explicitly
        // stopped, so return sticky.
        return START_STICKY;
    }

}

  • 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-28T01:36:04+00:00Added an answer on May 28, 2026 at 1:36 am

    I found the answer for this myself…

    the error,rather say;my mistake in coding was that i was supposed to use moveToNext() instead of isAfterLast()

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

Sidebar

Related Questions

I have a Php application using stream_socket_client(), to get data through tcp from a
I'm building an application using gevent. My app is getting rather big now as
I make a java application using netbeans that connect to database , but i
I have this application using CAL. All the modules derive from a special class,
I have a web application using ASP.NET 2.0 and I want to know if
I am developing an application using MVC Preview 5. I have used typed views.
An older application using System.Web.Mail is throwing an exception on emails coming from hr@domain.com
When starting a django application using python manage.py shell , I get an InteractiveConsole
i have built application using codeigniter, my controller name is userReg , in controller
I am developing application using phonegap in eclipse for android .I have created folder

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.