Get list view id using apex class in salesforce first we need to describe organization sobject by using below function
Step 1 -
Schema.getGlobalDescribe() - This map contains organization object. map populate during run time based on permission. Key of map is sobject name and value is Sobject tokens.token is serializeable reference to sobject.
Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();
Step 2-
Suppose if we want to describe Standard object account then we need to retrieve account token from map,If your org have namespace then you need to add namespace to custom object name because map contains object name with namespace as key.
Schema.SObjectType accInfo = Schema.getGlobalDescribe().get( 'Account' );
Step 3-
Now we will describe Account object using getDescribe(), Return result is not serializeble, result contains all describe property of object or fields
DescribeSObjectResult accDesc = accInfo.getDescribe();
Step 4-
Now we need to reterive object List view id from descrbie sobject result.
String listViewId = accDesc.getKeyPrefix();