`

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());

                                } 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics