I've solved this problem by:

public final static String SQL_GET_ALL_TABLES = "SELECT name FROM " +
                "sqlite_master WHERE type='table' ORDER BY name";
Cursor cur = dataBase.rawQuery(this.SQL_GET_ALL_TABLES, null);

The table names can be obtained from cur.
Thank all the people above!


On 7月29日, 下午12时34分, Marco Nelissen <marc...@android.com> wrote:
> If the database was created by you, shouldn't you already know which tables
> are in it?
>
> On Tue, Jul 28, 2009 at 6:18 PM, guishenl...@gmail.com <
>
>
>
> guishenl...@gmail.com> wrote:
>
> > I want to get the tables programmatically not in the command line. And
> > the database is created by myself not the contact database. Could you
> > give me some example code?
> > Thank you very much in advance!
>
> > On 7月28日, 下午9时46分, "Yusuf T. Mobile" <yusuf.s...@t-mobile.com> wrote:
> > > It depends if you want all the tables programmatically or if you can
> > > do it in the command line. Sujay's answer was from the command line.
> > > So starting a few steps back, you type:
>
> > > > adb shell
>
> > > # cd /data/data
> > > # cd com.android.providers.contacts
> > > # cd databases
> > > # sqlite3 contacts.db
> > > SQLite version 3.5.9
> > > Enter ".help" for instructions
> > > sqlite> .tables
>
> > > That will get you all the tables in the contacts database, for
> > > example. If that doesn't answer your question, let me know more about
> > > what you need and I'll try to help.
>
> > > Yusuf Saib
> > > Android
> > > ·T· · ·Mobile· stick together
> > > The views, opinions and statements in this email are those of the
> > > author solely in their individual capacity, and do not necessarily
> > > represent those of T-Mobile USA, Inc.
>
> > > On Jul 28, 12:59 am, "guishenl...@gmail.com" <guishenl...@gmail.com>
> > > wrote:
>
> > > > Thank you for answering!
> > > > But I didn't catch your real meaning.
> > > > Could you give me some exact code to show your point?
>
> > > > On 7月28日, 下午3时25分, Sujay Krishna Suresh <sujay.coold...@gmail.com>
> > > > wrote:
>
> > > > > .tables is the sql instruction to retrieve all the tables in the db.
> > > > > try executing it asa sql statement with rawQuery.
>
> > > > > On Tue, Jul 28, 2009 at 12:45 PM, guishenl...@gmail.com <
>
> > > > > guishenl...@gmail.com> wrote:
>
> > > > > > Hi all,
> > > > > >      I'm working at an application about SQLite database. I have
> > > > > > inserted some table in an database file.  But I don't know how to
> > get
> > > > > > all the tables' name using code. For example, I defined a database
> > > > > > object
> > > > > > SQLiteDatabase dataBase = SQLiteDatabase.openOrCreateDatabase(
> > > > > >                        getDatabasePath("Mydatabase"), null);
> > > > > > and how can I get all the table names stored in the database file
> > > > > > "Mydatabase". Counld anyone give me some code to help me?
> > > > > > Thank you in advance!
>
> > > > > --
> > > > > Regards,
> > > > > Sujay
> > > > > Joan Crawford<
> >http://www.brainyquote.com/quotes/authors/j/joan_crawford.html>
> > > > > - "I, Joan Crawford, I believe in the dollar. Everything I earn, I
> > > > > spend."- 隐藏被引用文字 -
>
> > > - 显示引用的文字 -- 隐藏被引用文字 -
>
> - 显示引用的文字 -
--~--~---------~--~----~------------~-------~--~----~
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