android - Null Pointer Exception after importing data from csv to sqlite -


I am getting a zero pointer exception when trying to import some lines from a CSV file into a SQLite database is. I'm getting a method when I call a method db.addProduct (...)

This is my code:

  Public class increases ImportDataHandler activity Is {secure file file; Protected DatabasesSandler DB; Private Arrestist and Lieutenant; Hashmap & lt; String, Object & gt; & Gt; My list; See protected list view list; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.importer); import data(); ListView = (ListView) findViewById (R.id.allProdList); Mylist = New Arrestist & lt; Hashmap & lt; String, Object & gt; & Gt; (); DB = new database scanner (this); If (db.getAllProducts (). IsEmpty ()) {Log.i (tap, "this is empty"); } If (! Db.getAllProducts () .isEmpty ()) {Log.i (db.getAllProducts (.) ToString (), "Products"); (Product P: DB.actualproduct ()) {Hashmap   

Database Assistant:

  Expands public class database scandalizer SQLiteOpenHelper {// database version personal static final end DATABASE_VERSION = 1; // Database Name Personal Static Last String DATABASE_NAME = "List Manager"; Private static final string TABLE_PRODUCTS = "product"; // Product Table Column Name Personal Static Last String KEY_ID = "id"; Private static final string KEY_PRODUCT_SKUCODE = "skuCode"; Personal Static Last String KEY_PRODUCT_NAME = "name"; Personal Static Last String KEY_PRODUCT_DESCRIPTION = "Description"; Private static final string KEY_PRODUCT_PRICE = "value"; Private static final string KEY_PRODUCT_IMAGE = "image"; Private static final string KEY_PRODUCT_CATEGORY = "category"; // Create a product personalized static final string CREATE_PRODUCT_TABLE = "Create Table" + TABLE_PRODUCTS + "(" + KEY_ID + "Inkender Primary Key," + KEY_PRODUCT_SKUCODE + "TEXT," + KEY_PRODUCT_NAME + "TEXT," + KEY_PRODUCT_DESCRIPTION + "text, "+ KEY_PRODUCT_PRICE +" INTEGER, "+ KEY_PRODUCT_IMAGE +" TEXT, "+ KEY_PRODUCT_CATEGORY +" INTEGER "+") "; Public databashendler (reference reference) {super (references, database, ANN, blank, databasebessons); } // Creating a table @ Override Creating at Zero Zero (SQLiteDatabase DB) {db.execSQL (CREATE_PRODUCT_TABLE); } // Upgrade Databases @Uprider Upgrade to Public Zero (SQLiteDatabase DB, Int Old Warson, Int Newversion) {// Drop Down Table if exists, then DB.XXQL ("Rick Table exists in" + Tabule programs); // Create again on table (db); } / ** * All CRUDs (Create, Read, Update, Delete) Operations * / Public Zero AddProduct (Product Products) {SQLiteDatabase DB = this.getWritableDatabase (); Material values ​​= new material value (); Values.put (KEY_PRODUCT_SKUCODE, product.getSkuCode ()); Values.put (KEY_PRODUCT_NAME, product.getName ()); Values.put (KEY_PRODUCT_DESCRIPTION, product.getDescription ()); Values.put (KEY_PRODUCT_PRICE, product.getPrice ()); Values.put (KEY_PRODUCT_IMAGE, product.getImage ()); Values.put (KEY_PRODUCT_CATEGORY, product.getCategory ()); Db.insert (TABLE_PRODUCTS, zero, value); Db.close (); }}   

Any help would be greatly appreciated

thanks.

In your code, it seems that you call "db" before "importData" Getting started, the reason for this is empty.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -