public static List<String> findAllTableNames(SQLiteDatabase db){
  List<String> tableNames=new ArrayList<String>();
  Cursor cursor=null;
  try {
    cursor=db.rawQuery("select * from sqlite_master where type = ?",new String[]{"table"});
    if (cursor.moveToFirst()) {
      do {
        String tableName=cursor.getString(cursor.getColumnIndexOrThrow("tbl_name"));
        if (!tableNames.contains(tableName)) {
          tableNames.add(tableName);
        }
      }
 while (cursor.moveToNext());
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new DatabaseGenerateException(e.getMessage());
  }
 finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  return tableNames;
}

public static List < String > findAllTableNames ( SQLiteDatabase db ) { List < String > tableNames = new ArrayList < String > ( ) ; Cursor cursor = null ; try { cursor = db . rawQuery ( "select * from sqlite_master where type = ?" , new String [ ] { "table" } ) ; if ( cursor . moveToFirst ( ) ) { do { String tableName = cursor . getString ( cursor . getColumnIndexOrThrow ( "tbl_name" ) ) ; if ( ! tableNames . contains ( tableName ) ) { tableNames . add ( tableName ) ; } } while ( cursor . moveToNext ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; throw new DatabaseGenerateException ( e . getMessage ( ) ) ; } finally { if ( cursor != null ) { cursor . close ( ) ; } } return tableNames ; }
find all table names in the database . if there ' s some wrong happens when finding tables , it will throw exceptions .
