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
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/
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);
}
Have fun:
http://sqlitebrowser.sourceforge.net/index.html
Edit:
and then the solution is already on StackOverflow: Ship an application with a database
精彩评论