Note that there are some explanatory texts on larger screens.

plurals
  1. POdatabase fail to create
    primarykey
    data
    text
    <p>The following code it does not create database file in /data/data/.The application run successfully in emulator. How can I use that created database file to upgrade that database using third party applications?</p> <p><strong>tapdb.java</strong></p> <pre><code>package com.android.tap; // entry has not been cre import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class tapdb { public static final String KEY_ROWID="_id"; public static final String KEY_CODE="key_code"; public static final String KEY_WORD="word"; public static final String DATABASE_NAME="tapdatabase"; public static final String DATABASE_TABLE="tapData"; public static final int DATABASE_VERSION=1; private DbHelper ourHelper; private final Context ourContext; private SQLiteDatabase ourDatabase; private static class DbHelper extends SQLiteOpenHelper { public DbHelper(Context context) { super(context,DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE" + DATABASE_TABLE + "(" +KEY_WORD + "TEXT NOT NULL" KEY_CODE + "LONG);"); db.execSQL("INSERT INTO tapdatabase VALUES('hello',23334);"); db.execSQL("INSERT INTO tapdatabase VALUES('how',242);"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS" + DATABASE_TABLE ); onCreate(db); } } public tapdb (Context c) { ourContext = c; } public tapdb open() { ourHelper = new DbHelper(ourContext); ourDatabase = ourHelper.getWritableDatabase(); return this; } public void close(){ ourHelper.close(); } public long createEntry(String word,String keycode){ ContentValues cv = new ContentValues(); cv.put(KEY_WORD, word); cv.put(KEY_CODE, keycode); return ourDatabase.insert(DATABASE_TABLE, null, cv); } public String getWord(long l) { String[] columns = new String[] {KEY_ROWID, KEY_WORD, KEY_CODE}; Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_ROWID + "=" + l, null, null, null, null); if (c != null) { c.moveToFirst(); String hotness = c.getString(1); return hotness; } return null; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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