I'm writing an app for Android. I have to read a txt file and write the data in the SQLite file. I have been successful in completing all the code, but in that part where the values in the database should be entered, it is not working. I have given the code given below:
Try {content value value = new content value (); Values.put (KEY_NAME, first number); // contact name values.put (KEY_PH_NO, strfinal); // Contact Phone // Line DB Insert insert (tabeline, property, value); } Hold (exception e) {e.printStackTrace (); } This code is not entering values in the database and the database remains empty after the operation is complete. what's wrong with that? Thank you. EDIT: OK, here is the full code:
public class database bands expanding SQLiteOpenHelper {// All static variables // database version private static final integer DATABASE_VERSION = 1; // Database Name Personal Static Last String DATABASE_NAME = "feedsmanager.sqlite"; // Contact table name personal constant last string TABLE_CONTACTS = "table_to_hold_all_values"; // Contact table column name personal constant last string KEY_ID = "id"; Private static final string KEY_NAME = "name"; // ctid private constant last string KEY_PH_NO = "phone_number"; // feedname, address; Feedname; Address etc reference ctx; Public databashendler (reference reference) {super (references, database, ANN, blank, databasebessons); Ctx reference =; } // Creating a table override public whit on a form (SQLiteDatabase db) {//Log.d ("On in Create", "Twitch 1"); String CREATE_CONTACTS_TABLE = "Create Table" + TABLE_CONTACTS + "(" + KEY_ID + "Inkender Primary Key," + KEY_NAME + "TEXT," + KEY_PH_NO + "TEXT);"; // log D. (LibLo v. Contact), "Twitch 1"); Try {db.execSQL (CREATE_CONTACTS_TABLE); } Hold (exception e) {log d. ("Making went wrong:" + E, "twitch 11")}} // log (Debel DBXxcL "," Twitch 1 "); Populate (Database);} Empty Populate (SQLiteDatabase dbs) {String Line =" "; Try {InputStream = ctx.getAssets ()} Open (" Feedchats and Addresses. Txt "); InputStreamReader iz = New InputStreamReader (); BuffettDrR BR = New buffated reader (iz); // SQLiteDatabase; DBS = this.getWritableDatabase (); while ((line = br.readline ()) = null) { // log (here fixed 6 "," twitch 1 "); StringTokenizer stringtoconizer = New string locator (line, "& lt;"); String firstumber = ""; String Stranfinal = ""; FirstNumber = (string) stringToKonizer NXtaille (); ** // To calculate the first digits and strfinal excluded contentValues values = new ContentValues (); Values.put (KEY_NAME, first number); // contact name values.put (KEY_PH_NO, strfinal); // Contact Phone // Line DBS insert insert (tabelagont act, empty, value);} dbs.close ();} hold (exception e) {log d. ("Yes error is" + e, "twitch 12"); }}}
this.db.insert (TABLE_CONTACTS, zero, value ); . Because I had the same problem a few months ago and this is the solution.
No comments:
Post a Comment