5

I have this database file under the usual databases folder and a bunch of tables inside it.

Please note that I don't want to retrieve under the command line. I know I can use the ".tables" command.

I want to retrieve a list of all tables in it, using code, so that I can execute some specific algorithms on each of them.

Also, I didn't find any questions with this problem on Android, so please forgive me if there is any. I was wondering if there is any function I can use under DatabaseUtils, but I didn't find any either.

0

1 Answer 1

14

Use

select name from sqlite_master where type = 'table' 
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much. Just adding to the answer, I noticed that there are two columns with the same values for sqlite_master, at least on Android: name and tbl_name. I saw on Google something about them (tbl_name, particularly) being the same for tables, just being different (name) to other stuff. So I should be safe reading from tbl_name whenever I want to retrieve the table name, right?
No, you should stick to 'name'.
from sqlite.org/faq.html ... For indices [...] name is the name of the index and tbl_name is the name of the table to which the index belongs.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.