I need to open google maps using kml file wich already exists on sdcard. (/sdcard/example.kml)
I tried:
Open local KML File in Google Maps on Androi
since your app might or might not have access to the sdcard (it might or might not be available, for instance), the surest solution is to post KML file to the web and charge it back (i assume that you have web access because google maps isnt going to be of much use offline, even prefetching tiles).
even if you have to pay a penalty (googlemaps is slow in parsing and embedding kml features), it is worth it, IMO.
for example, if you use a sample kml file (like the one below):
String kmlWebAddress = "http://www.afischer-online.de/sos/AFTrack/tracks/e1/01.24.Soltau2Wietzendorf.kml";
String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%s",kmlWebAddress);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
tested and working. just post your kml file to a fileserver and access it that way.
NOTE: if you plan on updating your map in realtime, googlemaps tends to avoid that by caching files for a certain period of time (undetermined). if you use a randomizer at the end of your kml string, like ?randomizer=[RandomNumber] you might be able to get away with realtime updating.