Approach: 1
Use FileExtension as '.sonte' when creating the Content Note using ContentVersion Object.Ex:
ContentVersion objCntNote = new ContentVersion();
objCntNote.Title = 'Test Content Note';
objCntNote.PathOnClient = objCntNote.Title + '.snote';
objCntNote.VersionData = Blob.valueOf('This is Test Content Note');
objCntNote.FirstPublishLocationId = '001G000002Baxlj'; // ParentId
insert objCntNote;
System.debug('cntNote Id == > '+objCntNote);
Result
Approach: 2
Use ContentNote object to create Content Note
Ex:
ContentNote objCntNote = new ContentNote();
objCntNote.Title = 'salesforce code crack';
objCntNote.Content = Blob.valueOf('Welcome to salesforcecodecrack.com');
insert objCntNote; //Insert Content Note
//create ContentDocumentLink record to link with parentId
ContentDocumentLink objCntDocLink = new ContentDocumentLink();
objCntDocLink.LinkedEntityId = '001G000002Baxlj'; // Specify your parent Id
objCntDocLink.ContentDocumentId = objCntNote.Id; //Content Note Id
objCntDocLink.shareType = 'V'; // Specify your sharing type
insert objCntDocLink;