0

I've completed developing the first phase of my application. I wanted to test it on an actual device so hooked up my mobile to my computer and installed the application. This application uses a database, so when I run my app on my mobile it throws an error

W/System.err(21912): android.database.sqlite.SQLiteException: no such table: UserTable: , while compiling: SELECT * FROM UserTable WHERE username='null'

How can I insert my database into my device during runtime ?

Regular method of inserting it through Eclipse wont work as root access is blocked by the mobile phone.

Vinoth
  • 1,339
  • 6
  • 23
  • 42
  • Got my answer. Refer to the link http://stackoverflow.com/questions/7268908/access-the-phone-internal-storage-to-push-in-sqlite-database-file – Vinoth Nov 21 '11 at 10:55

2 Answers2

1
    public class _DBHelper extends SQLiteOpenHelper {
    @Override
        public void onCreate(SQLiteDatabase db) {
            try {
                db.execSQL(strCREATE_TABLE1);
                InitTables(db);
            } catch (Exception e) {
                Log.i(this.getClass().getName(), e.getMessage());
            }

        }

        private void InitTables(SQLiteDatabase db) {
            ContentValues cv = new ContentValues();
            cv.put("colName", "...");
            //..
            db.insert("MyTable", "id", cv);
        }

    }
Bob
  • 22,810
  • 38
  • 143
  • 225
0

Please refer to this guide :

http://www.vogella.de/articles/AndroidSQLite/article.html

For creating new table you have to write the code in onCreate(SQLiteDatabase database) method and then in

onUpgrade(SQLiteDatabase database, int oldVersion,
            int newVersion) pass the new version.
Ravi Sharma
  • 873
  • 7
  • 24
  • I am not creating a new table, or creating a new database. I already have a database that I must insert into my testing device. – Vinoth Nov 21 '11 at 10:37
  • Is your device attached with PC? If yes then please detach it and then try because your device memory is used by PC. – Ravi Sharma Nov 21 '11 at 10:41