>From the looks of it you're going to need to read up on SQLite. This
is where I got started:

http://www.devx.com/wireless/Article/40842/0/page/1

But to import data to a database in your app, you need to do something
like this...

SQLiteDatabase db;
BufferedReader inFile;
String iLine;
try{
   inFile = new BufferedReader(new FileReader("/sdcard/[your file
name]"));  // open your file
}catch(FileNotFoundException e){
   // do something if file does not exist
}

try{
   ContentValues inputvalues = new ContentValues();
   iLine = inFile.readLine();  // read line from file
   while(iLine != null){
       String[] elements = iLine.split(",");  <-- i'm using a csv file
as an example
       inputvalues.put("column1", elements[1]);  <-- substitute your
db column names
       inputvalues.put("column2", elements[2]);
       inputvalues.put("column3", elements[3]);
       db.insert("database_name", null, inputvalues);  // insert
values into database
       iLine = inFile.readLine();   // read next line
   }
   inFile.close();
}catch(Exception e){
   // do something
}

You cannot issue command-line instructions like '.table' from the app,
I think that is were you are getting confused. You interact with the
database like a *database*, meaning you need to use SQL commands like
you would on SQL Server or Oracle.

Ken

On Dec 1, 1:53 pm, dsukhram <duanesukh...@gmail.com> wrote:
> Thanks for your reply Chad. However I was just using the '.tables'
> command as an example. What I really need to do is run the '.read'
> command in order to load data into my db
>
> On Dec 1, 1:21 pm, chad ziccardi <c...@digitalfreaks.org> wrote:
>
>
>
> > On Dec 1, 2009, at 9:32 AM, dsukhram wrote:
>
> > > When I try to run the '.tables' command by doing the following:
>
> > > SQLiteDatabase db = this.openOrCreateDatabase(DB_NAME, MODE_PRIVATE,
> > > null);
> > > db.execSQL(".tables");
>
> > Try this:
> > db.execSQL("SELECT name FROM sqlite_master where type='table' and name NOT 
> > LIKE 'sqlite_%';");

-- 
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

Reply via email to