Gainster
Gainster

Reputation: 5631

SQLite Database to Android

I have a requirement, where I have to move data from text into SQLite DB on Android.

One way to do this was to move the text file to asset manager and from there I can insert data into the DB.

Is there any way through which I can insert all the data into the SQlite DB using Desktop app and then just ship the SQLite DB with the android app

Upvotes: 0

Views: 907

Answers (3)

Waza_Be
Waza_Be

Reputation: 39577

Have fun:

http://sqlitebrowser.sourceforge.net/index.html

Edit:

and then the solution is already on StackOverflow: Ship an application with a database

Upvotes: 0

GSree
GSree

Reputation: 2898

This should help you.

Prepare the sqllite in desktop and then transfer it over to android

http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

Upvotes: 1

user319940
user319940

Reputation: 3317

Depending on how much data needs to be input, you could also do it from within the application. E.g.

 void InsertDepts(SQLiteDatabase db)
     {
         ContentValues cv=new ContentValues();
            cv.put(colDeptID, 1);
            cv.put(colDeptName, "Sales");
            db.insert(deptTable, colDeptID, cv);
            cv.put(colDeptID, 2);
            cv.put(colDeptName, "IT");
            db.insert(deptTable, colDeptID, cv);
            cv.put(colDeptID, 3);
            cv.put(colDeptName, "HR");
            db.insert(deptTable, colDeptID, cv);
            db.insert(deptTable, colDeptID, cv);

     }

Upvotes: 0

Related Questions