Note that there are some explanatory texts on larger screens.

plurals
  1. PODataBase Insertion
    primarykey
    data
    text
    <p>In my app i want to get password from the edit text and i want to store it in the data base on button Click</p> <p>In my main Activity i am getting the password value,Code is..</p> <pre><code> db_obj = new OpenHelper(getApplicationContext()) {}; okBtn = (Button)findViewById(R.id.okbtn); passwordTxt = (TextView)findViewById(R.id.editText1); passwordTxtValue = passwordTxt.getText().toString(); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String id1 = Integer.toString(id); passwordTxtValue = passwordTxt.getText().toString(); Toast.makeText(SetteingsPage.this, passwordTxtValue, Toast.LENGTH_SHORT).show(); System.out.println("pa"+passwordTxtValue); db_obj.password_varification(id1, passwordTxtValue); } </code></pre> <p>In openHelper i had created the dataBase as...</p> <pre><code>static final String password_table = "password_db"; static final String table_id = "table_id"; static final String password = "password"; public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE "+password_table+"("+table_id+" INTEGER PRIMARY KEY, "+password+" TEXT)"); } public void password_varification(String tableid ,String paswrd ) { SQLiteDatabase db=this.getWritableDatabase(); ContentValues cv=new ContentValues(); cv.put(table_id, tableid); cv.put(password, paswrd); db.insert(password_table, table_id, cv); db.close(); Log.v("DB", "Inset_User OK" + tableid + " " + paswrd); } // password Data retrive here public ArrayList&lt;HashMap&lt;String, String&gt;&gt; password_records() { SQLiteDatabase db=getReadableDatabase(); ArrayList&lt;HashMap&lt;String, String&gt;&gt; list = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); Cursor cursor=db.rawQuery("SELECT "+table_id+" as _id, "+password+" from "+password_table,new String [] {}); //Cursor cursor=db.rawQuery("SELECT "+row+" as _id, "+twitter+" from "+winery_info_2,new String [] {}); if(cursor!=null) { if(cursor.moveToFirst()) // movies first column { do { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); String fnam = cursor.getString(cursor.getColumnIndex("password")); map.put (password ,fnam); list.add(map); } while(cursor.moveToNext()); // move to next row } } if (cursor != null &amp;&amp; !cursor.isClosed()) { cursor.close(); } return list; } </code></pre> <p>But still When i am tring to insert the value it showing the error that "No such table"..how can i solve it</p> <p>The logCat ouput is</p> <pre><code> 01-08 16:06:33.273: E/Database(12305): Error inserting password_db 01-08 16:06:33.273: E/Database(12305): android.database.sqlite.SQLiteException: no such table: password_db: , while compiling: INSERT INTO password_db(table_id, password) VALUES(?, ?); 01-08 16:06:33.273: E/Database(12305): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) 01-08 16:06:33.273: E/Database(12305): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92) 01-08 16:06:33.273: E/Database(12305): at android.database.sqlite.SQLiteCompiledSql.&lt;init&gt;(SQLiteCompiledSql.java:65) 01-08 16:06:33.273: E/Database(12305): at android.database.sqlite.SQLiteProgram. &lt;init&gt;(SQLiteProgram.java:83) 01-08 16:06:33.273: E/Database(12305): at android.database.sqlite.SQLiteStatement.&lt;init&gt;(SQLiteStatement.java:41) 01-08 16:06:33.273: E/Database(12305): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1151) 01-08 16:06:33.273: E/Database(12305): at com.example.security.database.OpenHelper.password_varification(OpenHelper.java:98) 01-08 16:06:33.273: E/Database(12305): at com.example.security.Setting.SetteingsPage$2.onClick(SetteingsPage.java:51) 01-08 16:06:33.273: E/Database(12305): at android.view.View.performClick(View.java:2485) 01-08 16:06:33.273: E/Database(12305): at android.view.View$PerformClick.run(View.java:9080) 01-08 16:06:33.273: E/Database(12305): at android.os.Handler.handleCallback(Handler.java:587) 01-08 16:06:33.273: E/Database(12305): at android.os.Handler.dispatchMessage(Handler.java:92) 01-08 16:06:33.273: E/Database(12305): at android.os.Looper.loop(Looper.java:130) 01-08 16:06:33.273: E/Database(12305): at android.app.ActivityThread.main(ActivityThread.java:3687) 01-08 16:06:33.273: E/Database(12305): at java.lang.reflect.Method.invokeNative(Native Method) 01-08 16:06:33.273: E/Database(12305): at java.lang.reflect.Method.invoke(Method.java:507) 01-08 16:06:33.273: E/Database(12305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 01-08 16:06:33.273: E/Database(12305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 01-08 16:06:33.273: E/Database(12305): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    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.
 

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