[android-developers] Re: Android - InputStream SQLiteDatabase - How to read more than one xml file
Thank You for the answer.
I'm new in android so can you explain to me with an example and some
code?
Thanks
On 24 Dic, 14:15, Agus <agus.sant...@gmail.com> wrote:
> use transactions, it will be much faster
>
>
>
>
>
>
>
> On Fri, Dec 24, 2010 at 5: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+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home