我正在努力提高我的android数据库插入速度.我目前正在做的是生成一个字符串,如:
SELECT ? as title, ? as musician_id, ? as album_id, ? as genre
UNION SELECT ?, ?, ?, ?
UNION SELECT ?, ?, ?, ?
UNION SELECT ?, ?, ?, ?
UNION SELECT ?, ?, ?, ?
UNION SELECT ?, ?, ?, ?
Run Code Online (Sandbox Code Playgroud)
然后执行它
SQLiteDatabase database = //initialized in some way
String insertQuery; // the string of the query above
String [] parameters; // the parameters to use in the insertion.
database.execSQL(insertQuery.toString(), parameters);
Run Code Online (Sandbox Code Playgroud)
当我尝试插入大约2000行时,我收到以下错误:
Caused by: android.database.sqlite.SQLiteException: too many …Run Code Online (Sandbox Code Playgroud)