Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Log - causing application crash
    primarykey
    data
    text
    <p>Well I am working on an android application, to upload photos on FTP server. The application was working fine, I tried to modify the code and get the user data in log file using <strong>Log.v</strong>. </p> <p>Now here my problems starts, each and every time I tries to run my application it crashes. </p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SQLiteDatabase db = openOrCreateDatabase("userData",MODE_PRIVATE,null); db.execSQL("CREATE TABLE IF NOT EXISTS UserInfo(firstname VARCHAR,lastname VARCHAR);"); db.execSQL("INSERT INTO UserInfo VALUES('pulkit','gupta');"); Cursor c = db.rawQuery("SELECT * FROM UserInfo",null); //Log.d("result",c.getString(c.getColumnIndex("firstname"))); db.close(); } </code></pre> <p><strong>attaching my log image ..</strong></p> <pre><code>12-09 07:23:19.825: E/Trace(1942): error opening trace file: No such file or directory (2) 12-09 07:23:21.165: D/AndroidRuntime(1942): Shutting down VM 12-09 07:23:21.165: W/dalvikvm(1942): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 12-09 07:23:21.196: E/AndroidRuntime(1942): FATAL EXCEPTION: main 12-09 07:23:21.196: E/AndroidRuntime(1942): java.lang.RuntimeException: Unable to start activity ComponentInfo{abc.photoapp/abc.photoapp.MainActivity}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 12 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.ActivityThread.access$600(ActivityThread.java:141) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.os.Handler.dispatchMessage(Handler.java:99) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.os.Looper.loop(Looper.java:137) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.ActivityThread.main(ActivityThread.java:5041) 12-09 07:23:21.196: E/AndroidRuntime(1942): at java.lang.reflect.Method.invokeNative(Native Method) 12-09 07:23:21.196: E/AndroidRuntime(1942): at java.lang.reflect.Method.invoke(Method.java:511) 12-09 07:23:21.196: E/AndroidRuntime(1942): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 12-09 07:23:21.196: E/AndroidRuntime(1942): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 12-09 07:23:21.196: E/AndroidRuntime(1942): at dalvik.system.NativeStart.main(Native Method) 12-09 07:23:21.196: E/AndroidRuntime(1942): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 12 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:424) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) 12-09 07:23:21.196: E/AndroidRuntime(1942): at abc.photoapp.MainActivity.onCreate(MainActivity.java:29) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.Activity.performCreate(Activity.java:5104) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 12-09 07:23:21.196: E/AndroidRuntime(1942): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 12-09 07:23:21.196: E/AndroidRuntime(1942): ... 11 more </code></pre> <p><strong>My AVD Configurations</strong></p> <p><strong>Device: 4.0" WVGA (480x800 hdpi) Target: Android 4.2.2 – API Level 17 CPU/ABI: ARM (armabi-v7a) RAM 512</strong></p> <p><strong>can any one help me out the solution of my problem</strong> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload