Im fetching all records from a specific row of a db as follows,
public StatutoryModel getStatutoryRow(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_KNOWLEDGE_STATUTORY, new String[] { KEY_ID,
KEY_STATUTORY_MAPPING, KEY_LOCATION, KEY_DESCRIPTION,KEY_ACTIVE,KEY_PROVISION,KEY_COMPLIANCE_TASK,KEY_FORMAT_FILE_LIST,KEY_DURATION,KEY_DOC_NAME,KEY_PENAL_CONSEQUENCE,KEY_DURATION_ID,KEY_FREQUENCY_ID,KEY_REPEAT_FREQ,KEY_COMPLIANCE_ID,KEY_REPEAT_TYPE_ID,KEY_STATUTORY_MONTH}, KEY_ID + "=?",
new String[] { String.valueOf(id) }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
StatutoryModel contact = new StatutoryModel(Integer.parseInt(cursor.getString(0)), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9), Integer.parseInt(cursor.getString(10)), cursor.getString(11), cursor.getString(12), Integer.parseInt(cursor.getString(13)), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18), cursor.getString(19));
// return contact
return contact;
}
And Im invoking it as follows,
Db.getInstance(getApplicationContext()).getStatutoryRow(1).getDescription()
The issue is that im getting numberformatexception when Im trying to do so. Following is my error log
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.activities/com.activities.StatutoryDecision}: java.lang.NumberFormatException: Invalid int: "" at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) at android.app.ActivityThread.access$700(ActivityThread.java:159) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NumberFormatException: Invalid int: "" at java.lang.Integer.invalidInt(Integer.java:138) at java.lang.Integer.parseInt(Integer.java:359) at java.lang.Integer.parseInt(Integer.java:332) at com.Controllers.Db.getStatutoryRow(Db.java:292) at com.activities.StatutoryDecision.onCreate(StatutoryDecision.java:44) at android.app.Activity.performCreate(Activity.java:5372) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) at android.app.ActivityThread.access$700(ActivityThread.java:159) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) at dalvik.system.NativeStart.main(Native Method)
Aucun commentaire:
Enregistrer un commentaire