android 使用SQLiteOpenHelper类批量执行sql问题

try {

        InputStream in = mContext.getAssets().open("update_cities.sql");

        SQLiteDatabase database = getWritableDatabase();

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));

        String sqlUpdate = null;

         while ((sqlUpdate = bufferedReader.readLine()) != null) {

                    if (!TextUtils.isEmpty(sqlUpdate)) {

                            database.execSQL(sqlUpdate);

                                                }

                                        }

                         bufferedReader.close();

                         in.close();

         } catch (SQLException e) {

                     XLog.log(TAG, e.getMessage());

          } catch (IOException e) {

                     XLog.log(TAG, e.getMessage());

                                } 

 

你可能感兴趣的:(android)