If you're doing this to load up the DB, it's simpler/faster to just include the pre-built DB in your app and then copy it to the right place once installed. (Be sure to name it .jpg or some such if larger than 1M to avoid the compression mess.)
On Dec 24, 4:39 am, giuseppe <giuma...@gmail.com> wrote: > I'have this code > > public class DatabaseHelper extends SQLiteOpenHelper { > > public static final String DATABASE_NAME = "prova"; > > protected Context context; > > public DatabaseHelper(Context context) { > super(context, DATABASE_NAME, null, 1); > this.context = context; > } > > @Override > public void onCreate(SQLiteDatabase db) { > String s; > try { > Toast.makeText(context, "1", 2000).show(); > InputStream in = > context.getResources().openRawResource(R.raw.mysql); > DocumentBuilder builder = > DocumentBuilderFactory.newInstance().newDocumentBuilder(); > Document doc = builder.parse(in, null); > NodeList statements = doc.getElementsByTagName("st"); > for (int i=0; i<st.getLength(); i++) { > s = > st.item(i).getChildNodes().item(0).getNodeValue(); > db.execSQL(s); > } > } catch (Throwable t) { > Toast.makeText(context, t.toString(), 50000).show(); > } > } > > @Override > public void onUpgrade(SQLiteDatabase db, int oldVersion, int > newVersion) { > db.execSQL("DROP TABLE IF EXISTS employees"); > onCreate(db); > } > > } > > This class read myxml file and executes sql instruction that are in > the statements . > > Because the XML file is about 4MB I'have to split it in three or four > files, but I don't know how to modify the code to do this. Thanks for > any suggestion. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en